{"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAssetRegistry","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IAssetRegistry","name":"newVal","type":"address"}],"name":"AssetRegistrySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IBackingManager","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IBackingManager","name":"newVal","type":"address"}],"name":"BackingManagerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IBasketHandler","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IBasketHandler","name":"newVal","type":"address"}],"name":"BasketHandlerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IBroker","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IBroker","name":"newVal","type":"address"}],"name":"BrokerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDistributor","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IDistributor","name":"newVal","type":"address"}],"name":"DistributorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IFurnace","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IFurnace","name":"newVal","type":"address"}],"name":"FurnaceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint48","name":"oldDuration","type":"uint48"},{"indexed":true,"internalType":"uint48","name":"newDuration","type":"uint48"}],"name":"LongFreezeDurationSet","type":"event"},{"anonymous":false,"inputs":[],"name":"MainInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bool","name":"oldVal","type":"bool"},{"indexed":true,"internalType":"bool","name":"newVal","type":"bool"}],"name":"PausedSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IRevenueTrader","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IRevenueTrader","name":"newVal","type":"address"}],"name":"RSRTraderSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IRToken","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IRToken","name":"newVal","type":"address"}],"name":"RTokenSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IRevenueTrader","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IRevenueTrader","name":"newVal","type":"address"}],"name":"RTokenTraderSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint48","name":"oldDuration","type":"uint48"},{"indexed":true,"internalType":"uint48","name":"newDuration","type":"uint48"}],"name":"ShortFreezeDurationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IStRSR","name":"oldVal","type":"address"},{"indexed":true,"internalType":"contract IStRSR","name":"newVal","type":"address"}],"name":"StRSRSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint48","name":"oldVal","type":"uint48"},{"indexed":true,"internalType":"uint48","name":"newVal","type":"uint48"}],"name":"UnfreezeAtSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LONG_FREEZER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OWNER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SHORT_FREEZER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetRegistry","outputs":[{"internalType":"contract IAssetRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"backingManager","outputs":[{"internalType":"contract IBackingManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"basketHandler","outputs":[{"internalType":"contract IBasketHandler","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"broker","outputs":[{"internalType":"contract IBroker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributor","outputs":[{"internalType":"contract IDistributor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"freezeForever","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"freezeLong","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"freezeShort","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"frozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"furnace","outputs":[{"internalType":"contract IFurnace","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IRToken","name":"rToken","type":"address"},{"internalType":"contract IStRSR","name":"stRSR","type":"address"},{"internalType":"contract IAssetRegistry","name":"assetRegistry","type":"address"},{"internalType":"contract IBasketHandler","name":"basketHandler","type":"address"},{"internalType":"contract IBackingManager","name":"backingManager","type":"address"},{"internalType":"contract IDistributor","name":"distributor","type":"address"},{"internalType":"contract IFurnace","name":"furnace","type":"address"},{"internalType":"contract IBroker","name":"broker","type":"address"},{"internalType":"contract IRevenueTrader","name":"rsrTrader","type":"address"},{"internalType":"contract IRevenueTrader","name":"rTokenTrader","type":"address"}],"internalType":"struct Components","name":"components","type":"tuple"},{"internalType":"contract IERC20","name":"rsr_","type":"address"},{"internalType":"uint48","name":"shortFreeze_","type":"uint48"},{"internalType":"uint48","name":"longFreeze_","type":"uint48"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"longFreeze","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"longFreezes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pausedOrFrozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poke","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rToken","outputs":[{"internalType":"contract IRToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rTokenTrader","outputs":[{"internalType":"contract IRevenueTrader","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rsr","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rsrTrader","outputs":[{"internalType":"contract IRevenueTrader","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint48","name":"longFreeze_","type":"uint48"}],"name":"setLongFreeze","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"shortFreeze_","type":"uint48"}],"name":"setShortFreeze","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shortFreeze","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stRSR","outputs":[{"internalType":"contract IStRSR","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unfreeze","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unfreezeAt","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}],"additional_sources":[{"file_path":"/IRewardable.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./IComponent.sol\";\nimport \"./IMain.sol\";\n\n/**\n * @title IRewardable\n * @notice A simple interface mixin to support claiming of rewards.\n */\ninterface IRewardable {\n    /// Emitted whenever a reward token balance is claimed\n    event RewardsClaimed(IERC20 indexed erc20, uint256 indexed amount);\n\n    /// Claim rewards earned by holding a balance of the ERC20 token\n    /// Must emit `RewardsClaimed` for each token rewards are claimed for\n    /// @dev delegatecall: there be dragons here!\n    /// @custom:interaction\n    function claimRewards() external;\n}\n\n/**\n * @title IRewardableComponent\n * @notice A simple interface mixin to support claiming of rewards.\n */\ninterface IRewardableComponent is IRewardable {\n    /// Claim rewards for a single ERC20\n    /// Must emit `RewardsClaimed` for each token rewards are claimed for\n    /// @dev delegatecall: there be dragons here!\n    /// @custom:interaction\n    function claimRewardsSingle(IERC20 erc20) external;\n}\n"},{"file_path":"/IGnosis.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nstruct GnosisAuctionData {\n    IERC20 auctioningToken;\n    IERC20 biddingToken;\n    uint256 orderCancellationEndDate;\n    uint256 auctionEndDate;\n    bytes32 initialAuctionOrder;\n    uint256 minimumBiddingAmountPerOrder;\n    uint256 interimSumBidAmount;\n    bytes32 interimOrder;\n    bytes32 clearingPriceOrder;\n    uint96 volumeClearingPriceOrder;\n    bool minFundingThresholdNotReached;\n    bool isAtomicClosureAllowed;\n    uint256 feeNumerator;\n    uint256 minFundingThreshold;\n}\n\n/// The relevant portion of the interface of the live Gnosis EasyAuction contract\n/// https://github.com/gnosis/ido-contracts/blob/main/contracts/EasyAuction.sol\ninterface IGnosis {\n    function initiateAuction(\n        IERC20 auctioningToken,\n        IERC20 biddingToken,\n        uint256 orderCancellationEndDate,\n        uint256 auctionEndDate,\n        uint96 auctionedSellAmount,\n        uint96 minBuyAmount,\n        uint256 minimumBiddingAmountPerOrder,\n        uint256 minFundingThreshold,\n        bool isAtomicClosureAllowed,\n        address accessManagerContract,\n        bytes memory accessManagerContractData\n    ) external returns (uint256 auctionId);\n\n    function auctionData(uint256 auctionId) external view returns (GnosisAuctionData memory);\n\n    /// @param auctionId The external auction id\n    /// @dev See here for decoding: https://git.io/JMang\n    /// @return encodedOrder The order, encoded in a bytes 32\n    function settleAuction(uint256 auctionId) external returns (bytes32 encodedOrder);\n\n    /// @return The numerator over a 1000-valued denominator\n    function feeNumerator() external returns (uint256);\n}\n"},{"file_path":"/IBroker.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"./IAsset.sol\";\nimport \"./IComponent.sol\";\nimport \"./IGnosis.sol\";\nimport \"./ITrade.sol\";\n\n/// The data format that describes a request for trade with the Broker\nstruct TradeRequest {\n    IAsset sell;\n    IAsset buy;\n    uint256 sellAmount; // {qSellTok}\n    uint256 minBuyAmount; // {qBuyTok}\n}\n\n/**\n * @title IBroker\n * @notice The Broker deploys oneshot Trade contracts for Traders and monitors\n *   the continued proper functioning of trading platforms.\n */\ninterface IBroker is IComponent {\n    event AuctionLengthSet(uint48 indexed oldVal, uint48 indexed newVal);\n    event DisabledSet(bool indexed prevVal, bool indexed newVal);\n\n    // Initialization\n    function init(\n        IMain main_,\n        IGnosis gnosis_,\n        ITrade tradeImplementation_,\n        uint48 auctionLength_\n    ) external;\n\n    /// Request a trade from the broker\n    /// @dev Requires setting an allowance in advance\n    /// @custom:interaction\n    function openTrade(TradeRequest memory req) external returns (ITrade);\n\n    /// Only callable by one of the trading contracts the broker deploys\n    function reportViolation() external;\n\n    function disabled() external view returns (bool);\n}\n\ninterface TestIBroker is IBroker {\n    function gnosis() external view returns (IGnosis);\n\n    function auctionLength() external view returns (uint48);\n\n    function setAuctionLength(uint48 newAuctionLength) external;\n\n    function setDisabled(bool disabled_) external;\n}\n"},{"file_path":"/Fixed.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\n// solhint-disable func-name-mixedcase func-visibility\npragma solidity ^0.8.17;\n\n/// @title FixedPoint, a fixed-point arithmetic library defining the custom type uint192\n/// @author Matt Elder <matt.elder@reserve.org> and the Reserve Team <https://reserve.org>\n\n/** The logical type `uint192 ` is a 192 bit value, representing an 18-decimal Fixed-point\n    fractional value.  This is what's described in the Solidity documentation as\n    \"fixed192x18\" -- a value represented by 192 bits, that makes 18 digits available to\n    the right of the decimal point.\n\n    The range of values that uint192 can represent is about [-1.7e20, 1.7e20].\n    Unless a function explicitly says otherwise, it will fail on overflow.\n    To be clear, the following should hold:\n    toFix(0) == 0\n    toFix(1) == 1e18\n*/\n\n// Analysis notes:\n//   Every function should revert iff its result is out of bounds.\n//   Unless otherwise noted, when a rounding mode is given, that mode is applied to\n//     a single division that may happen as the last step in the computation.\n//   Unless otherwise noted, when a rounding mode is *not* given but is needed, it's FLOOR.\n//   For each, we comment:\n//   - @return is the value expressed  in \"value space\", where uint192(1e18) \"is\" 1.0\n//   - as-ints: is the value expressed in \"implementation space\", where uint192(1e18) \"is\" 1e18\n//   The \"@return\" expression is suitable for actually using the library\n//   The \"as-ints\" expression is suitable for testing\n\n// A uint value passed to this library was out of bounds for uint192 operations\nerror UIntOutOfBounds();\nbytes32 constant UIntOutofBoundsHash = keccak256(abi.encodeWithSignature(\"UIntOutOfBounds()\"));\n\n// Used by P1 implementation for easier casting\nuint256 constant FIX_ONE_256 = 1e18;\nuint8 constant FIX_DECIMALS = 18;\n\n// If a particular uint192 is represented by the uint192 n, then the uint192 represents the\n// value n/FIX_SCALE.\nuint64 constant FIX_SCALE = 1e18;\n\n// FIX_SCALE Squared:\nuint128 constant FIX_SCALE_SQ = 1e36;\n\n// The largest integer that can be converted to uint192 .\n// This is a bit bigger than 3.1e39\nuint192 constant FIX_MAX_INT = type(uint192).max / FIX_SCALE;\n\nuint192 constant FIX_ZERO = 0; // The uint192 representation of zero.\nuint192 constant FIX_ONE = FIX_SCALE; // The uint192 representation of one.\nuint192 constant FIX_MAX = type(uint192).max; // The largest uint192. (Not an integer!)\nuint192 constant FIX_MIN = 0; // The smallest uint192.\n\n/// An enum that describes a rounding approach for converting to ints\nenum RoundingMode {\n    FLOOR, // Round towards zero\n    ROUND, // Round to the nearest int\n    CEIL // Round away from zero\n}\n\nRoundingMode constant FLOOR = RoundingMode.FLOOR;\nRoundingMode constant ROUND = RoundingMode.ROUND;\nRoundingMode constant CEIL = RoundingMode.CEIL;\n\n/* @dev Solidity 0.8.x only allows you to change one of type or size per type conversion.\n   Thus, all the tedious-looking double conversions like uint256(uint256 (foo))\n   See: https://docs.soliditylang.org/en/v0.8.17/080-breaking-changes.html#new-restrictions\n */\n\n/// Explicitly convert a uint256 to a uint192. Revert if the input is out of bounds.\nfunction _safeWrap(uint256 x) pure returns (uint192) {\n    if (FIX_MAX < x) revert UIntOutOfBounds();\n    return uint192(x);\n}\n\n/// Convert a uint to its Fix representation.\n/// @return x\n// as-ints: x * 1e18\nfunction toFix(uint256 x) pure returns (uint192) {\n    return _safeWrap(x * FIX_SCALE);\n}\n\n/// Convert a uint to its fixed-point representation, and left-shift its value `shiftLeft`\n/// decimal digits.\n/// @return x * 10**shiftLeft\n// as-ints: x * 10**(shiftLeft + 18)\nfunction shiftl_toFix(uint256 x, int8 shiftLeft) pure returns (uint192) {\n    return shiftl_toFix(x, shiftLeft, FLOOR);\n}\n\n/// @return x * 10**shiftLeft\n// as-ints: x * 10**(shiftLeft + 18)\nfunction shiftl_toFix(\n    uint256 x,\n    int8 shiftLeft,\n    RoundingMode rounding\n) pure returns (uint192) {\n    // conditions for avoiding overflow\n    if (x == 0) return 0;\n    if (shiftLeft <= -96) return (rounding == CEIL ? 1 : 0); // 0 < uint.max / 10**77 < 0.5\n    if (40 <= shiftLeft) revert UIntOutOfBounds(); // 10**56 < FIX_MAX < 10**57\n\n    shiftLeft += 18;\n\n    uint256 coeff = 10**abs(shiftLeft);\n    uint256 shifted = (shiftLeft >= 0) ? x * coeff : _divrnd(x, coeff, rounding);\n\n    return _safeWrap(shifted);\n}\n\n/// Divide a uint by a uint192, yielding a uint192\n/// This may also fail if the result is MIN_uint192! not fixing this for optimization's sake.\n/// @return x / y\n// as-ints: x * 1e36 / y\nfunction divFix(uint256 x, uint192 y) pure returns (uint192) {\n    // If we didn't have to worry about overflow, we'd just do `return x * 1e36 / _y`\n    // If it's safe to do this operation the easy way, do it:\n    if (x < uint256(type(uint256).max / FIX_SCALE_SQ)) {\n        return _safeWrap(uint256(x * FIX_SCALE_SQ) / y);\n    } else {\n        return _safeWrap(mulDiv256(x, FIX_SCALE_SQ, y));\n    }\n}\n\n/// Divide a uint by a uint, yielding a  uint192\n/// @return x / y\n// as-ints: x * 1e18 / y\nfunction divuu(uint256 x, uint256 y) pure returns (uint192) {\n    return _safeWrap(mulDiv256(FIX_SCALE, x, y));\n}\n\n/// @return min(x,y)\n// as-ints: min(x,y)\nfunction fixMin(uint192 x, uint192 y) pure returns (uint192) {\n    return x < y ? x : y;\n}\n\n/// @return max(x,y)\n// as-ints: max(x,y)\nfunction fixMax(uint192 x, uint192 y) pure returns (uint192) {\n    return x > y ? x : y;\n}\n\n/// @return absoluteValue(x,y)\n// as-ints: absoluteValue(x,y)\nfunction abs(int256 x) pure returns (uint256) {\n    return x < 0 ? uint256(-x) : uint256(x);\n}\n\n/// Divide two uints, returning a uint, using rounding mode `rounding`.\n/// @return numerator / divisor\n// as-ints: numerator / divisor\nfunction _divrnd(\n    uint256 numerator,\n    uint256 divisor,\n    RoundingMode rounding\n) pure returns (uint256) {\n    uint256 result = numerator / divisor;\n\n    if (rounding == FLOOR) return result;\n\n    if (rounding == ROUND) {\n        if (numerator % divisor > (divisor - 1) / 2) {\n            result++;\n        }\n    } else {\n        if (numerator % divisor > 0) {\n            result++;\n        }\n    }\n\n    return result;\n}\n\nlibrary FixLib {\n    /// Again, all arithmetic functions fail if and only if the result is out of bounds.\n\n    /// Convert this fixed-point value to a uint. Round towards zero if needed.\n    /// @return x\n    // as-ints: x / 1e18\n    function toUint(uint192 x) internal pure returns (uint136) {\n        return toUint(x, FLOOR);\n    }\n\n    /// Convert this uint192 to a uint\n    /// @return x\n    // as-ints: x / 1e18 with rounding\n    function toUint(uint192 x, RoundingMode rounding) internal pure returns (uint136) {\n        return uint136(_divrnd(uint256(x), FIX_SCALE, rounding));\n    }\n\n    /// Return the uint192 shifted to the left by `decimal` digits\n    /// (Similar to a bitshift but in base 10)\n    /// @return x * 10**decimals\n    // as-ints: x * 10**decimals\n    function shiftl(uint192 x, int8 decimals) internal pure returns (uint192) {\n        return shiftl(x, decimals, FLOOR);\n    }\n\n    /// Return the uint192 shifted to the left by `decimal` digits\n    /// (Similar to a bitshift but in base 10)\n    /// @return x * 10**decimals\n    // as-ints: x * 10**decimals\n    function shiftl(\n        uint192 x,\n        int8 decimals,\n        RoundingMode rounding\n    ) internal pure returns (uint192) {\n        // Handle overflow cases\n        if (x == 0) return 0;\n        if (decimals <= -59) return (rounding == CEIL ? 1 : 0); // 59, because 1e58 > 2**192\n        if (58 <= decimals) revert UIntOutOfBounds(); // 58, because x * 1e58 > 2 ** 192 if x != 0\n\n        uint256 coeff = uint256(10**abs(decimals));\n        return _safeWrap(decimals >= 0 ? x * coeff : _divrnd(x, coeff, rounding));\n    }\n\n    /// Add a uint192 to this uint192\n    /// @return x + y\n    // as-ints: x + y\n    function plus(uint192 x, uint192 y) internal pure returns (uint192) {\n        return x + y;\n    }\n\n    /// Add a uint to this uint192\n    /// @return x + y\n    // as-ints: x + y*1e18\n    function plusu(uint192 x, uint256 y) internal pure returns (uint192) {\n        return _safeWrap(x + y * FIX_SCALE);\n    }\n\n    /// Subtract a uint192 from this uint192\n    /// @return x - y\n    // as-ints: x - y\n    function minus(uint192 x, uint192 y) internal pure returns (uint192) {\n        return x - y;\n    }\n\n    /// Subtract a uint from this uint192\n    /// @return x - y\n    // as-ints: x - y*1e18\n    function minusu(uint192 x, uint256 y) internal pure returns (uint192) {\n        return _safeWrap(uint256(x) - uint256(y * FIX_SCALE));\n    }\n\n    /// Multiply this uint192 by a uint192\n    /// Round truncated values to the nearest available value. 5e-19 rounds away from zero.\n    /// @return x * y\n    // as-ints: x * y/1e18  [division using ROUND, not FLOOR]\n    function mul(uint192 x, uint192 y) internal pure returns (uint192) {\n        return mul(x, y, ROUND);\n    }\n\n    /// Multiply this uint192 by a uint192\n    /// @return x * y\n    // as-ints: x * y/1e18\n    function mul(\n        uint192 x,\n        uint192 y,\n        RoundingMode rounding\n    ) internal pure returns (uint192) {\n        return _safeWrap(_divrnd(uint256(x) * uint256(y), FIX_SCALE, rounding));\n    }\n\n    /// Multiply this uint192 by a uint\n    /// @return x * y\n    // as-ints: x * y\n    function mulu(uint192 x, uint256 y) internal pure returns (uint192) {\n        return _safeWrap(x * y);\n    }\n\n    /// Divide this uint192 by a uint192\n    /// @return x / y\n    // as-ints: x * 1e18 / y\n    function div(uint192 x, uint192 y) internal pure returns (uint192) {\n        return div(x, y, FLOOR);\n    }\n\n    /// Divide this uint192 by a uint192\n    /// @return x / y\n    // as-ints: x * 1e18 / y\n    function div(\n        uint192 x,\n        uint192 y,\n        RoundingMode rounding\n    ) internal pure returns (uint192) {\n        // Multiply-in FIX_SCALE before dividing by y to preserve precision.\n        return _safeWrap(_divrnd(uint256(x) * FIX_SCALE, y, rounding));\n    }\n\n    /// Divide this uint192 by a uint\n    /// @return x / y\n    // as-ints: x / y\n    function divu(uint192 x, uint256 y) internal pure returns (uint192) {\n        return divu(x, y, FLOOR);\n    }\n\n    /// Divide this uint192 by a uint\n    /// @return x / y\n    // as-ints: x / y\n    function divu(\n        uint192 x,\n        uint256 y,\n        RoundingMode rounding\n    ) internal pure returns (uint192) {\n        return _safeWrap(_divrnd(x, y, rounding));\n    }\n\n    uint64 constant FIX_HALF = uint64(FIX_SCALE) / 2;\n\n    /// Raise this uint192 to a nonnegative integer power. Requires that x_ <= FIX_ONE\n    /// Gas cost is O(lg(y)), precision is +- 1e-18.\n    /// @return x_ ** y\n    // as-ints: x_ ** y / 1e18**(y-1)    <- technically correct for y = 0. :D\n    function powu(uint192 x_, uint48 y) internal pure returns (uint192) {\n        require(x_ <= FIX_ONE);\n        if (y == 1) return x_;\n        if (x_ == FIX_ONE || y == 0) return FIX_ONE;\n        uint256 x = uint256(x_) * FIX_SCALE; // x is D36\n        uint256 result = FIX_SCALE_SQ; // result is D36\n        while (true) {\n            if (y & 1 == 1) result = (result * x + FIX_SCALE_SQ / 2) / FIX_SCALE_SQ;\n            if (y <= 1) break;\n            y = (y >> 1);\n            x = (x * x + FIX_SCALE_SQ / 2) / FIX_SCALE_SQ;\n        }\n        return _safeWrap(result / FIX_SCALE);\n    }\n\n    /// Comparison operators...\n    function lt(uint192 x, uint192 y) internal pure returns (bool) {\n        return x < y;\n    }\n\n    function lte(uint192 x, uint192 y) internal pure returns (bool) {\n        return x <= y;\n    }\n\n    function gt(uint192 x, uint192 y) internal pure returns (bool) {\n        return x > y;\n    }\n\n    function gte(uint192 x, uint192 y) internal pure returns (bool) {\n        return x >= y;\n    }\n\n    function eq(uint192 x, uint192 y) internal pure returns (bool) {\n        return x == y;\n    }\n\n    function neq(uint192 x, uint192 y) internal pure returns (bool) {\n        return x != y;\n    }\n\n    /// Return whether or not this uint192 is less than epsilon away from y.\n    /// @return |x - y| < epsilon\n    // as-ints: |x - y| < epsilon\n    function near(\n        uint192 x,\n        uint192 y,\n        uint192 epsilon\n    ) internal pure returns (bool) {\n        uint192 diff = x <= y ? y - x : x - y;\n        return diff < epsilon;\n    }\n\n    // ================ Chained Operations ================\n    // The operation foo_bar() always means:\n    //   Do foo() followed by bar(), and overflow only if the _end_ result doesn't fit in an uint192\n\n    /// Shift this uint192 left by `decimals` digits, and convert to a uint\n    /// @return x * 10**decimals\n    // as-ints: x * 10**(decimals - 18)\n    function shiftl_toUint(uint192 x, int8 decimals) internal pure returns (uint256) {\n        return shiftl_toUint(x, decimals, FLOOR);\n    }\n\n    /// Shift this uint192 left by `decimals` digits, and convert to a uint.\n    /// @return x * 10**decimals\n    // as-ints: x * 10**(decimals - 18)\n    function shiftl_toUint(\n        uint192 x,\n        int8 decimals,\n        RoundingMode rounding\n    ) internal pure returns (uint256) {\n        // Handle overflow cases\n        if (x == 0) return 0; // always computable, no matter what decimals is\n        if (decimals <= -42) return (rounding == CEIL ? 1 : 0);\n        if (96 <= decimals) revert UIntOutOfBounds();\n\n        decimals -= 18; // shift so that toUint happens at the same time.\n\n        uint256 coeff = uint256(10**abs(decimals));\n        return decimals >= 0 ? uint256(x * coeff) : uint256(_divrnd(x, coeff, rounding));\n    }\n\n    /// Multiply this uint192 by a uint, and output the result as a uint\n    /// @return x * y\n    // as-ints: x * y / 1e18\n    function mulu_toUint(uint192 x, uint256 y) internal pure returns (uint256) {\n        return mulDiv256(uint256(x), y, FIX_SCALE);\n    }\n\n    /// Multiply this uint192 by a uint, and output the result as a uint\n    /// @return x * y\n    // as-ints: x * y / 1e18\n    function mulu_toUint(\n        uint192 x,\n        uint256 y,\n        RoundingMode rounding\n    ) internal pure returns (uint256) {\n        return mulDiv256(uint256(x), y, FIX_SCALE, rounding);\n    }\n\n    /// Multiply this uint192 by a uint192 and output the result as a uint\n    /// @return x * y\n    // as-ints: x * y / 1e36\n    function mul_toUint(uint192 x, uint192 y) internal pure returns (uint256) {\n        return mulDiv256(uint256(x), uint256(y), FIX_SCALE_SQ);\n    }\n\n    /// Multiply this uint192 by a uint192 and output the result as a uint\n    /// @return x * y\n    // as-ints: x * y / 1e36\n    function mul_toUint(\n        uint192 x,\n        uint192 y,\n        RoundingMode rounding\n    ) internal pure returns (uint256) {\n        return mulDiv256(uint256(x), uint256(y), FIX_SCALE_SQ, rounding);\n    }\n\n    /// Compute x * y / z avoiding intermediate overflow\n    /// @dev Only use if you need to avoid overflow; costlier than x * y / z\n    /// @return x * y / z\n    // as-ints: x * y / z\n    function muluDivu(\n        uint192 x,\n        uint256 y,\n        uint256 z\n    ) internal pure returns (uint192) {\n        return muluDivu(x, y, z, FLOOR);\n    }\n\n    /// Compute x * y / z, avoiding intermediate overflow\n    /// @dev Only use if you need to avoid overflow; costlier than x * y / z\n    /// @return x * y / z\n    // as-ints: x * y / z\n    function muluDivu(\n        uint192 x,\n        uint256 y,\n        uint256 z,\n        RoundingMode rounding\n    ) internal pure returns (uint192) {\n        return _safeWrap(mulDiv256(x, y, z, rounding));\n    }\n\n    /// Compute x * y / z on Fixes, avoiding intermediate overflow\n    /// @dev Only use if you need to avoid overflow; costlier than x * y / z\n    /// @return x * y / z\n    // as-ints: x * y / z\n    function mulDiv(\n        uint192 x,\n        uint192 y,\n        uint192 z\n    ) internal pure returns (uint192) {\n        return mulDiv(x, y, z, FLOOR);\n    }\n\n    /// Compute x * y / z on Fixes, avoiding intermediate overflow\n    /// @dev Only use if you need to avoid overflow; costlier than x * y / z\n    /// @return x * y / z\n    // as-ints: x * y / z\n    function mulDiv(\n        uint192 x,\n        uint192 y,\n        uint192 z,\n        RoundingMode rounding\n    ) internal pure returns (uint192) {\n        return _safeWrap(mulDiv256(x, y, z, rounding));\n    }\n}\n\n// ================ a couple pure-uint helpers================\n// as-ints comments are omitted here, because they're the same as @return statements, because\n// these are all pure uint functions\n\n/// Return (x*y/z), avoiding intermediate overflow.\n//  Adapted from sources:\n//    https://medium.com/coinmonks/4db014e080b1, https://medium.com/wicketh/afa55870a65\n//    and quite a few of the other excellent \"Mathemagic\" posts from https://medium.com/wicketh\n/// @dev Only use if you need to avoid overflow; costlier than x * y / z\n/// @return result x * y / z\nfunction mulDiv256(\n    uint256 x,\n    uint256 y,\n    uint256 z\n) pure returns (uint256 result) {\n    unchecked {\n        (uint256 hi, uint256 lo) = fullMul(x, y);\n        if (hi >= z) revert UIntOutOfBounds();\n        uint256 mm = mulmod(x, y, z);\n        if (mm > lo) hi -= 1;\n        lo -= mm;\n        uint256 pow2 = z & (0 - z);\n        z /= pow2;\n        lo /= pow2;\n        lo += hi * ((0 - pow2) / pow2 + 1);\n        uint256 r = 1;\n        r *= 2 - z * r;\n        r *= 2 - z * r;\n        r *= 2 - z * r;\n        r *= 2 - z * r;\n        r *= 2 - z * r;\n        r *= 2 - z * r;\n        r *= 2 - z * r;\n        r *= 2 - z * r;\n        result = lo * r;\n    }\n}\n\n/// Return (x*y/z), avoiding intermediate overflow.\n/// @dev Only use if you need to avoid overflow; costlier than x * y / z\n/// @return x * y / z\nfunction mulDiv256(\n    uint256 x,\n    uint256 y,\n    uint256 z,\n    RoundingMode rounding\n) pure returns (uint256) {\n    uint256 result = mulDiv256(x, y, z);\n    if (rounding == FLOOR) return result;\n\n    uint256 mm = mulmod(x, y, z);\n    if (rounding == CEIL) {\n        if (mm > 0) result += 1;\n    } else {\n        if (mm > ((z - 1) / 2)) result += 1; // z should be z-1\n    }\n    return result;\n}\n\n/// Return (x*y) as a \"virtual uint512\" (lo, hi), representing (hi*2**256 + lo)\n///   Adapted from sources:\n///   https://medium.com/wicketh/27650fec525d, https://medium.com/coinmonks/4db014e080b1\n/// @dev Intended to be internal to this library\n/// @return hi (hi, lo) satisfies  hi*(2**256) + lo == x * y\n/// @return lo (paired with `hi`)\nfunction fullMul(uint256 x, uint256 y) pure returns (uint256 hi, uint256 lo) {\n    unchecked {\n        uint256 mm = mulmod(x, y, uint256(0) - uint256(1));\n        lo = x * y;\n        hi = mm - lo;\n        if (mm < lo) hi -= 1;\n    }\n}\n"},{"file_path":"/IVersioned.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\ninterface IVersioned {\n    function version() external view returns (string memory);\n}\n"},{"file_path":"/IStRSR.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n// solhint-disable-next-line max-line-length\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../libraries/Fixed.sol\";\nimport \"./IComponent.sol\";\nimport \"./IMain.sol\";\n\n/**\n * @title IStRSR\n * @notice An ERC20 token representing shares of the RSR over-collateralization pool.\n *\n * StRSR permits the BackingManager to take RSR in times of need. In return, the BackingManager\n * benefits the StRSR pool with RSR rewards purchased with a portion of its revenue.\n *\n * In the absence of collateral default or losses due to slippage, StRSR should have a\n * monotonically increasing exchange rate with respect to RSR, meaning that over time\n * StRSR is redeemable for more RSR. It is non-rebasing.\n */\ninterface IStRSR is IERC20MetadataUpgradeable, IERC20PermitUpgradeable, IComponent {\n    /// Emitted when RSR is staked\n    /// @param era The era at time of staking\n    /// @param staker The address of the staker\n    /// @param rsrAmount {qRSR} How much RSR was staked\n    /// @param stRSRAmount {qStRSR} How much stRSR was minted by this staking\n    event Staked(\n        uint256 indexed era,\n        address indexed staker,\n        uint256 rsrAmount,\n        uint256 indexed stRSRAmount\n    );\n\n    /// Emitted when an unstaking is started\n    /// @param draftId The id of the draft.\n    /// @param draftEra The era of the draft.\n    /// @param staker The address of the unstaker\n    ///   The triple (staker, draftEra, draftId) is a unique ID\n    /// @param rsrAmount {qRSR} How much RSR this unstaking will be worth, absent seizures\n    /// @param stRSRAmount {qStRSR} How much stRSR was burned by this unstaking\n    event UnstakingStarted(\n        uint256 indexed draftId,\n        uint256 indexed draftEra,\n        address indexed staker,\n        uint256 rsrAmount,\n        uint256 stRSRAmount,\n        uint256 availableAt\n    );\n\n    /// Emitted when RSR is unstaked\n    /// @param firstId The beginning of the range of draft IDs withdrawn in this transaction\n    /// @param endId The end of range of draft IDs withdrawn in this transaction\n    ///   (ID i was withdrawn if firstId <= i < endId)\n    /// @param draftEra The era of the draft.\n    ///   The triple (staker, draftEra, id) is a unique ID among drafts\n    /// @param staker The address of the unstaker\n\n    /// @param rsrAmount {qRSR} How much RSR this unstaking was worth\n    event UnstakingCompleted(\n        uint256 indexed firstId,\n        uint256 indexed endId,\n        uint256 draftEra,\n        address indexed staker,\n        uint256 rsrAmount\n    );\n\n    /// Emitted whenever the exchange rate changes\n    event ExchangeRateSet(uint192 indexed oldVal, uint192 indexed newVal);\n\n    /// Emitted whenever RSR are paids out\n    event RewardsPaid(uint256 indexed rsrAmt);\n\n    /// Emitted if all the RSR in the staking pool is seized and all balances are reset to zero.\n    event AllBalancesReset(uint256 indexed newEra);\n    /// Emitted if all the RSR in the unstakin pool is seized, and all ongoing unstaking is voided.\n    event AllUnstakingReset(uint256 indexed newEra);\n\n    event UnstakingDelaySet(uint48 indexed oldVal, uint48 indexed newVal);\n    event RewardRatioSet(uint192 indexed oldVal, uint192 indexed newVal);\n\n    // Initialization\n    function init(\n        IMain main_,\n        string memory name_,\n        string memory symbol_,\n        uint48 unstakingDelay_,\n        uint192 rewardRatio_\n    ) external;\n\n    /// Gather and payout rewards from rsrTrader\n    /// @custom:interaction\n    function payoutRewards() external;\n\n    /// Stakes an RSR `amount` on the corresponding RToken to earn yield and over-collateralized\n    /// the system\n    /// @param amount {qRSR}\n    /// @custom:interaction\n    function stake(uint256 amount) external;\n\n    /// Begins a delayed unstaking for `amount` stRSR\n    /// @param amount {qStRSR}\n    /// @custom:interaction\n    function unstake(uint256 amount) external;\n\n    /// Complete delayed unstaking for the account, up to (but not including!) `endId`\n    /// @custom:interaction\n    function withdraw(address account, uint256 endId) external;\n\n    /// Seize RSR, only callable by main.backingManager()\n    /// @custom:protected\n    function seizeRSR(uint256 amount) external;\n\n    /// Return the maximum valid value of endId such that withdraw(endId) should immediately work\n    function endIdForWithdraw(address account) external view returns (uint256 endId);\n\n    /// @return {qRSR/qStRSR} The exchange rate between RSR and StRSR\n    function exchangeRate() external view returns (uint192);\n}\n\ninterface TestIStRSR is IStRSR {\n    function rewardRatio() external view returns (uint192);\n\n    function setRewardRatio(uint192) external;\n\n    function unstakingDelay() external view returns (uint48);\n\n    function setUnstakingDelay(uint48) external;\n\n    function increaseAllowance(address, uint256) external returns (bool);\n\n    function decreaseAllowance(address, uint256) external returns (bool);\n\n    /// @return {qStRSR/qRSR} The exchange rate between StRSR and RSR\n    function exchangeRate() external view returns (uint192);\n}\n"},{"file_path":"/ERC165Upgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n    function __ERC165_init() internal onlyInitializing {\n    }\n\n    function __ERC165_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165Upgradeable).interfaceId;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"},{"file_path":"/ContextUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"},{"file_path":"/IERC20Upgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"},{"file_path":"/extensions/IERC20MetadataUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"},{"file_path":"/IRToken.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n// solhint-disable-next-line max-line-length\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../libraries/Fixed.sol\";\nimport \"../libraries/Throttle.sol\";\nimport \"./IAsset.sol\";\nimport \"./IComponent.sol\";\nimport \"./IMain.sol\";\nimport \"./IRewardable.sol\";\n\n/**\n * @title IRToken\n * @notice An RToken is an ERC20 that is permissionlessly issuable/redeemable and tracks an\n *   exchange rate against a single unit: baskets, or {BU} in our type notation.\n */\ninterface IRToken is IComponent, IERC20MetadataUpgradeable, IERC20PermitUpgradeable {\n    /// Emitted when an issuance of RToken occurs, whether it occurs via slow minting or not\n    /// @param issuer The address holding collateral tokens\n    /// @param recipient The address of the recipient of the RTokens\n    /// @param amount The quantity of RToken being issued\n    /// @param baskets The corresponding number of baskets\n    event Issuance(\n        address indexed issuer,\n        address indexed recipient,\n        uint256 indexed amount,\n        uint192 baskets\n    );\n\n    /// Emitted when a redemption of RToken occurs\n    /// @param redeemer The address holding RToken\n    /// @param recipient The address of the account receiving the backing collateral tokens\n    /// @param amount The quantity of RToken being redeemed\n    /// @param baskets The corresponding number of baskets\n    /// @param amount {qRTok} The amount of RTokens canceled\n    event Redemption(\n        address indexed redeemer,\n        address indexed recipient,\n        uint256 indexed amount,\n        uint192 baskets\n    );\n\n    /// Emitted when the number of baskets needed changes\n    /// @param oldBasketsNeeded Previous number of baskets units needed\n    /// @param newBasketsNeeded New number of basket units needed\n    event BasketsNeededChanged(uint192 oldBasketsNeeded, uint192 newBasketsNeeded);\n\n    /// Emitted when RToken is melted, i.e the RToken supply is decreased but basketsNeeded is not\n    /// @param amount {qRTok}\n    event Melted(uint256 amount);\n\n    /// Emitted when issuance SupplyThrottle params are set\n    event IssuanceThrottleSet(ThrottleLib.Params oldVal, ThrottleLib.Params newVal);\n\n    /// Emitted when redemption SupplyThrottle params are set\n    event RedemptionThrottleSet(ThrottleLib.Params oldVal, ThrottleLib.Params newVal);\n\n    // Initialization\n    function init(\n        IMain main_,\n        string memory name_,\n        string memory symbol_,\n        string memory mandate_,\n        ThrottleLib.Params calldata issuanceThrottleParams,\n        ThrottleLib.Params calldata redemptionThrottleParams\n    ) external;\n\n    /// Issue an RToken with basket collateral\n    /// @param amount {qRTok} The quantity of RToken to issue\n    /// @custom:interaction\n    function issue(uint256 amount) external;\n\n    /// Issue an RToken with basket collateral, to a particular recipient\n    /// @param recipient The address to receive the issued RTokens\n    /// @param amount {qRTok} The quantity of RToken to issue\n    /// @custom:interaction\n    function issueTo(address recipient, uint256 amount) external;\n\n    /// Redeem RToken for basket collateral\n    /// @param amount {qRTok} The quantity {qRToken} of RToken to redeem\n    /// @param basketNonce The nonce of the basket the redemption should be from; else reverts\n    /// @custom:interaction\n    function redeem(uint256 amount, uint48 basketNonce) external;\n\n    /// Redeem RToken for basket collateral to a particular recipient\n    /// @param recipient The address to receive the backing collateral tokens\n    /// @param amount {qRTok} The quantity {qRToken} of RToken to redeem\n    /// @param basketNonce The nonce of the basket the redemption should be from; else reverts\n    /// @custom:interaction\n    function redeemTo(\n        address recipient,\n        uint256 amount,\n        uint48 basketNonce\n    ) external;\n\n    /// Mints a quantity of RToken to the `recipient`, callable only by the BackingManager\n    /// @param recipient The recipient of the newly minted RToken\n    /// @param amount {qRTok} The amount to be minted\n    /// @custom:protected\n    function mint(address recipient, uint256 amount) external;\n\n    /// Melt a quantity of RToken from the caller's account\n    /// @param amount {qRTok} The amount to be melted\n    function melt(uint256 amount) external;\n\n    /// Set the number of baskets needed directly, callable only by the BackingManager\n    /// @param basketsNeeded {BU} The number of baskets to target\n    ///                      needed range: pretty interesting\n    /// @custom:protected\n    function setBasketsNeeded(uint192 basketsNeeded) external;\n\n    /// @return {BU} How many baskets are being targeted\n    function basketsNeeded() external view returns (uint192);\n\n    /// @return {qRTok} The maximum issuance that can be performed in the current block\n    function issuanceAvailable() external view returns (uint256);\n\n    /// @return {qRTok} The maximum redemption that can be performed in the current block\n    function redemptionAvailable() external view returns (uint256);\n}\n\ninterface TestIRToken is IRToken {\n    function setIssuanceThrottleParams(ThrottleLib.Params calldata) external;\n\n    function setRedemptionThrottleParams(ThrottleLib.Params calldata) external;\n\n    function issuanceThrottleParams() external view returns (ThrottleLib.Params memory);\n\n    function redemptionThrottleParams() external view returns (ThrottleLib.Params memory);\n\n    function increaseAllowance(address, uint256) external returns (bool);\n\n    function decreaseAllowance(address, uint256) external returns (bool);\n\n    function monetizeDonations(IERC20) external;\n}\n"},{"file_path":"/IMain.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./IAssetRegistry.sol\";\nimport \"./IBasketHandler.sol\";\nimport \"./IBackingManager.sol\";\nimport \"./IBroker.sol\";\nimport \"./IGnosis.sol\";\nimport \"./IFurnace.sol\";\nimport \"./IDistributor.sol\";\nimport \"./IRToken.sol\";\nimport \"./IRevenueTrader.sol\";\nimport \"./IStRSR.sol\";\nimport \"./ITrading.sol\";\nimport \"./IVersioned.sol\";\n\n// === Auth roles ===\n\nbytes32 constant OWNER = bytes32(bytes(\"OWNER\"));\nbytes32 constant SHORT_FREEZER = bytes32(bytes(\"SHORT_FREEZER\"));\nbytes32 constant LONG_FREEZER = bytes32(bytes(\"LONG_FREEZER\"));\nbytes32 constant PAUSER = bytes32(bytes(\"PAUSER\"));\n\n/**\n * Main is a central hub that maintains a list of Component contracts.\n *\n * Components:\n *   - perform a specific function\n *   - defer auth to Main\n *   - usually (but not always) contain sizeable state that require a proxy\n */\nstruct Components {\n    // Definitely need proxy\n    IRToken rToken;\n    IStRSR stRSR;\n    IAssetRegistry assetRegistry;\n    IBasketHandler basketHandler;\n    IBackingManager backingManager;\n    IDistributor distributor;\n    IFurnace furnace;\n    IBroker broker;\n    IRevenueTrader rsrTrader;\n    IRevenueTrader rTokenTrader;\n}\n\ninterface IAuth is IAccessControlUpgradeable {\n    /// Emitted when `unfreezeAt` is changed\n    /// @param oldVal The old value of `unfreezeAt`\n    /// @param newVal The new value of `unfreezeAt`\n    event UnfreezeAtSet(uint48 indexed oldVal, uint48 indexed newVal);\n\n    /// Emitted when the short freeze duration governance param is changed\n    /// @param oldDuration The old short freeze duration\n    /// @param newDuration The new short freeze duration\n    event ShortFreezeDurationSet(uint48 indexed oldDuration, uint48 indexed newDuration);\n\n    /// Emitted when the long freeze duration governance param is changed\n    /// @param oldDuration The old long freeze duration\n    /// @param newDuration The new long freeze duration\n    event LongFreezeDurationSet(uint48 indexed oldDuration, uint48 indexed newDuration);\n\n    /// Emitted when the system is paused or unpaused\n    /// @param oldVal The old value of `paused`\n    /// @param newVal The new value of `paused`\n    event PausedSet(bool indexed oldVal, bool indexed newVal);\n\n    /**\n     * Paused: Disable everything except for OWNER actions, RToken.redeem, StRSR.stake,\n     * and StRSR.payoutRewards\n     * Frozen: Disable everything except for OWNER actions + StRSR.stake (for governance)\n     */\n\n    function pausedOrFrozen() external view returns (bool);\n\n    function frozen() external view returns (bool);\n\n    function shortFreeze() external view returns (uint48);\n\n    function longFreeze() external view returns (uint48);\n\n    // ====\n\n    // onlyRole(OWNER)\n    function freezeForever() external;\n\n    // onlyRole(SHORT_FREEZER)\n    function freezeShort() external;\n\n    // onlyRole(LONG_FREEZER)\n    function freezeLong() external;\n\n    // onlyRole(OWNER)\n    function unfreeze() external;\n\n    function pause() external;\n\n    function unpause() external;\n}\n\ninterface IComponentRegistry {\n    // === Component setters/getters ===\n\n    event RTokenSet(IRToken indexed oldVal, IRToken indexed newVal);\n\n    function rToken() external view returns (IRToken);\n\n    event StRSRSet(IStRSR indexed oldVal, IStRSR indexed newVal);\n\n    function stRSR() external view returns (IStRSR);\n\n    event AssetRegistrySet(IAssetRegistry indexed oldVal, IAssetRegistry indexed newVal);\n\n    function assetRegistry() external view returns (IAssetRegistry);\n\n    event BasketHandlerSet(IBasketHandler indexed oldVal, IBasketHandler indexed newVal);\n\n    function basketHandler() external view returns (IBasketHandler);\n\n    event BackingManagerSet(IBackingManager indexed oldVal, IBackingManager indexed newVal);\n\n    function backingManager() external view returns (IBackingManager);\n\n    event DistributorSet(IDistributor indexed oldVal, IDistributor indexed newVal);\n\n    function distributor() external view returns (IDistributor);\n\n    event RSRTraderSet(IRevenueTrader indexed oldVal, IRevenueTrader indexed newVal);\n\n    function rsrTrader() external view returns (IRevenueTrader);\n\n    event RTokenTraderSet(IRevenueTrader indexed oldVal, IRevenueTrader indexed newVal);\n\n    function rTokenTrader() external view returns (IRevenueTrader);\n\n    event FurnaceSet(IFurnace indexed oldVal, IFurnace indexed newVal);\n\n    function furnace() external view returns (IFurnace);\n\n    event BrokerSet(IBroker indexed oldVal, IBroker indexed newVal);\n\n    function broker() external view returns (IBroker);\n}\n\n/**\n * @title IMain\n * @notice The central hub for the entire system. Maintains components and an owner singleton role\n */\ninterface IMain is IVersioned, IAuth, IComponentRegistry {\n    function poke() external; // not used in p1\n\n    // === Initialization ===\n\n    event MainInitialized();\n\n    function init(\n        Components memory components,\n        IERC20 rsr_,\n        uint48 shortFreeze_,\n        uint48 longFreeze_\n    ) external;\n\n    function rsr() external view returns (IERC20);\n}\n\ninterface TestIMain is IMain {\n    /// @custom:governance\n    function setShortFreeze(uint48) external;\n\n    /// @custom:governance\n    function setLongFreeze(uint48) external;\n\n    function shortFreeze() external view returns (uint48);\n\n    function longFreeze() external view returns (uint48);\n\n    function longFreezes(address account) external view returns (uint256);\n\n    function paused() external view returns (bool);\n}\n"},{"file_path":"/IFurnace.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"../libraries/Fixed.sol\";\nimport \"./IComponent.sol\";\n\n/**\n * @title IFurnace\n * @notice A helper contract to burn RTokens slowly and permisionlessly.\n */\ninterface IFurnace is IComponent {\n    // Initialization\n    function init(IMain main_, uint192 ratio_) external;\n\n    /// Emitted when the melting ratio is changed\n    /// @param oldRatio The old ratio\n    /// @param newRatio The new ratio\n    event RatioSet(uint192 indexed oldRatio, uint192 indexed newRatio);\n\n    function ratio() external view returns (uint192);\n\n    ///    Needed value range: [0, 1], granularity 1e-9\n    /// @custom:governance\n    function setRatio(uint192) external;\n\n    /// Performs any RToken melting that has vested since the last payout.\n    /// @custom:refresher\n    function melt() external;\n}\n\ninterface TestIFurnace is IFurnace {\n    function lastPayout() external view returns (uint256);\n\n    function lastPayoutBal() external view returns (uint256);\n}\n"},{"file_path":"/IAsset.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"../libraries/Fixed.sol\";\nimport \"./IMain.sol\";\nimport \"./IRewardable.sol\";\n\n/**\n * @title IAsset\n * @notice Supertype. Any token that interacts with our system must be wrapped in an asset,\n * whether it is used as RToken backing or not. Any token that can report a price in the UoA\n * is eligible to be an asset.\n */\ninterface IAsset is IRewardable {\n    /// Refresh saved price\n    /// The Reserve protocol calls this at least once per transaction, before relying on\n    /// the Asset's other functions.\n    /// @dev Called immediately after deployment, before use\n    function refresh() external;\n\n    /// Should not revert\n    /// @return low {UoA/tok} The lower end of the price estimate\n    /// @return high {UoA/tok} The upper end of the price estimate\n    function price() external view returns (uint192 low, uint192 high);\n\n    /// Should not revert\n    /// lotLow should be nonzero when the asset might be worth selling\n    /// @return lotLow {UoA/tok} The lower end of the lot price estimate\n    /// @return lotHigh {UoA/tok} The upper end of the lot price estimate\n    function lotPrice() external view returns (uint192 lotLow, uint192 lotHigh);\n\n    /// @return {tok} The balance of the ERC20 in whole tokens\n    function bal(address account) external view returns (uint192);\n\n    /// @return The ERC20 contract of the token with decimals() available\n    function erc20() external view returns (IERC20Metadata);\n\n    /// @return The number of decimals in the ERC20; just for gas optimization\n    function erc20Decimals() external view returns (uint8);\n\n    /// @return If the asset is an instance of ICollateral or not\n    function isCollateral() external view returns (bool);\n\n    /// @param {UoA} The max trade volume, in UoA\n    function maxTradeVolume() external view returns (uint192);\n}\n\ninterface TestIAsset is IAsset {\n    function chainlinkFeed() external view returns (AggregatorV3Interface);\n}\n\n/// CollateralStatus must obey a linear ordering. That is:\n/// - being DISABLED is worse than being IFFY, or SOUND\n/// - being IFFY is worse than being SOUND.\nenum CollateralStatus {\n    SOUND,\n    IFFY, // When a peg is not holding or a chainlink feed is stale\n    DISABLED // When the collateral has completely defaulted\n}\n\n/// Upgrade-safe maximum operator for CollateralStatus\nlibrary CollateralStatusComparator {\n    /// @return Whether a is worse than b\n    function worseThan(CollateralStatus a, CollateralStatus b) internal pure returns (bool) {\n        return uint256(a) > uint256(b);\n    }\n}\n\n/**\n * @title ICollateral\n * @notice A subtype of Asset that consists of the tokens eligible to back the RToken.\n */\ninterface ICollateral is IAsset {\n    /// Emitted whenever the collateral status is changed\n    /// @param newStatus The old CollateralStatus\n    /// @param newStatus The updated CollateralStatus\n    event CollateralStatusChanged(\n        CollateralStatus indexed oldStatus,\n        CollateralStatus indexed newStatus\n    );\n\n    /// @dev refresh()\n    /// Refresh exchange rates and update default status.\n    /// VERY IMPORTANT: In any valid implemntation, status() MUST become DISABLED in refresh() if\n    /// refPerTok() has ever decreased since last call.\n\n    /// @return The canonical name of this collateral's target unit.\n    function targetName() external view returns (bytes32);\n\n    /// @return The status of this collateral asset. (Is it defaulting? Might it soon?)\n    function status() external view returns (CollateralStatus);\n\n    // ==== Exchange Rates ====\n\n    /// @return {ref/tok} Quantity of whole reference units per whole collateral tokens\n    function refPerTok() external view returns (uint192);\n\n    /// @return {target/ref} Quantity of whole target units per whole reference unit in the peg\n    function targetPerRef() external view returns (uint192);\n}\n"},{"file_path":"/IERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"},{"file_path":"/OwnableUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\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    function __Ownable_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions 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 virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"},{"file_path":"/ITrading.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../libraries/Fixed.sol\";\nimport \"./IAsset.sol\";\nimport \"./IComponent.sol\";\nimport \"./ITrade.sol\";\nimport \"./IRewardable.sol\";\n\n/**\n * @title ITrading\n * @notice Common events and refresher function for all Trading contracts\n */\ninterface ITrading is IComponent, IRewardableComponent {\n    event MaxTradeSlippageSet(uint192 indexed oldVal, uint192 indexed newVal);\n    event MinTradeVolumeSet(uint192 indexed oldVal, uint192 indexed newVal);\n\n    /// Emitted when a trade is started\n    /// @param trade The one-time-use trade contract that was just deployed\n    /// @param sell The token to sell\n    /// @param buy The token to buy\n    /// @param sellAmount {qSellTok} The quantity of the selling token\n    /// @param minBuyAmount {qBuyTok} The minimum quantity of the buying token to accept\n    event TradeStarted(\n        ITrade indexed trade,\n        IERC20 indexed sell,\n        IERC20 indexed buy,\n        uint256 sellAmount,\n        uint256 minBuyAmount\n    );\n\n    /// Emitted after a trade ends\n    /// @param trade The one-time-use trade contract\n    /// @param sell The token to sell\n    /// @param buy The token to buy\n    /// @param sellAmount {qSellTok} The quantity of the token sold\n    /// @param buyAmount {qBuyTok} The quantity of the token bought\n    event TradeSettled(\n        ITrade indexed trade,\n        IERC20 indexed sell,\n        IERC20 indexed buy,\n        uint256 sellAmount,\n        uint256 buyAmount\n    );\n\n    /// Settle a single trade, expected to be used with multicall for efficient mass settlement\n    /// @custom:refresher\n    function settleTrade(IERC20 sell) external;\n\n    /// @return {%} The maximum trade slippage acceptable\n    function maxTradeSlippage() external view returns (uint192);\n\n    /// @return {UoA} The minimum trade volume in UoA, applies to all assets\n    function minTradeVolume() external view returns (uint192);\n\n    /// @return The ongoing trade for a sell token, or the zero address\n    function trades(IERC20 sell) external view returns (ITrade);\n\n    /// Light wrapper around FixLib.mulDiv to support try-catch\n    function mulDivCeil(\n        uint192 x,\n        uint192 y,\n        uint192 z\n    ) external pure returns (uint192);\n}\n\ninterface TestITrading is ITrading {\n    /// @custom:governance\n    function setMaxTradeSlippage(uint192 val) external;\n\n    /// @custom:governance\n    function setMinTradeVolume(uint192 val) external;\n\n    /// @return The number of ongoing trades open\n    function tradesOpen() external view returns (uint48);\n}\n"},{"file_path":"/IAssetRegistry.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./IAsset.sol\";\nimport \"./IComponent.sol\";\n\n/// A serialization of the AssetRegistry to be passed around in the P1 impl for gas optimization\nstruct Registry {\n    IERC20[] erc20s;\n    IAsset[] assets;\n}\n\n/**\n * @title IAssetRegistry\n * @notice The AssetRegistry is in charge of maintaining the ERC20 tokens eligible\n *   to be handled by the rest of the system. If an asset is in the registry, this means:\n *      1. Its ERC20 contract has been vetted\n *      2. The asset is the only asset for that ERC20\n *      3. The asset can be priced in the UoA, usually via an oracle\n */\ninterface IAssetRegistry is IComponent {\n    /// Emitted when an asset is added to the registry\n    /// @param erc20 The ERC20 contract for the asset\n    /// @param asset The asset contract added to the registry\n    event AssetRegistered(IERC20 indexed erc20, IAsset indexed asset);\n\n    /// Emitted when an asset is removed from the registry\n    /// @param erc20 The ERC20 contract for the asset\n    /// @param asset The asset contract removed from the registry\n    event AssetUnregistered(IERC20 indexed erc20, IAsset indexed asset);\n\n    // Initialization\n    function init(IMain main_, IAsset[] memory assets_) external;\n\n    /// Fully refresh all asset state\n    /// @custom:interaction\n    function refresh() external;\n\n    /// @return The corresponding asset for ERC20, or reverts if not registered\n    function toAsset(IERC20 erc20) external view returns (IAsset);\n\n    /// @return The corresponding collateral, or reverts if unregistered or not collateral\n    function toColl(IERC20 erc20) external view returns (ICollateral);\n\n    /// @return If the ERC20 is registered\n    function isRegistered(IERC20 erc20) external view returns (bool);\n\n    /// @return A list of all registered ERC20s\n    function erc20s() external view returns (IERC20[] memory);\n\n    /// @return reg The list of registered ERC20s and Assets, in the same order\n    function getRegistry() external view returns (Registry memory reg);\n\n    function register(IAsset asset) external returns (bool);\n\n    function swapRegistered(IAsset asset) external returns (bool swapped);\n\n    function unregister(IAsset asset) external;\n}\n"},{"file_path":"/extensions/IERC20Metadata.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"},{"file_path":"/AddressUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"},{"file_path":"/ERC1967UpgradeUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeaconUpgradeable.sol\";\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/StorageSlotUpgradeable.sol\";\nimport \"../utils/Initializable.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967UpgradeUpgradeable is Initializable {\n    function __ERC1967Upgrade_init() internal onlyInitializing {\n    }\n\n    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {\n    }\n    // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n    /**\n     * @dev Storage slot with the address of the current implementation.\n     * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    /**\n     * @dev Emitted when the implementation is upgraded.\n     */\n    event Upgraded(address indexed implementation);\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function _getImplementation() internal view returns (address) {\n        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 implementation slot.\n     */\n    function _setImplementation(address newImplementation) private {\n        require(AddressUpgradeable.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n    }\n\n    /**\n     * @dev Perform implementation upgrade\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeTo(address newImplementation) internal {\n        _setImplementation(newImplementation);\n        emit Upgraded(newImplementation);\n    }\n\n    /**\n     * @dev Perform implementation upgrade with additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCall(\n        address newImplementation,\n        bytes memory data,\n        bool forceCall\n    ) internal {\n        _upgradeTo(newImplementation);\n        if (data.length > 0 || forceCall) {\n            _functionDelegateCall(newImplementation, data);\n        }\n    }\n\n    /**\n     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCallUUPS(\n        address newImplementation,\n        bytes memory data,\n        bool forceCall\n    ) internal {\n        // Upgrades from old implementations will perform a rollback test. This test requires the new\n        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n        // this special case will break upgrade paths from old UUPS implementation to new ones.\n        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {\n            _setImplementation(newImplementation);\n        } else {\n            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n                require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n            } catch {\n                revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n            }\n            _upgradeToAndCall(newImplementation, data, forceCall);\n        }\n    }\n\n    /**\n     * @dev Storage slot with the admin of the contract.\n     * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n    /**\n     * @dev Emitted when the admin account has changed.\n     */\n    event AdminChanged(address previousAdmin, address newAdmin);\n\n    /**\n     * @dev Returns the current admin.\n     */\n    function _getAdmin() internal view returns (address) {\n        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 admin slot.\n     */\n    function _setAdmin(address newAdmin) private {\n        require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n    }\n\n    /**\n     * @dev Changes the admin of the proxy.\n     *\n     * Emits an {AdminChanged} event.\n     */\n    function _changeAdmin(address newAdmin) internal {\n        emit AdminChanged(_getAdmin(), newAdmin);\n        _setAdmin(newAdmin);\n    }\n\n    /**\n     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n     */\n    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    /**\n     * @dev Emitted when the beacon is upgraded.\n     */\n    event BeaconUpgraded(address indexed beacon);\n\n    /**\n     * @dev Returns the current beacon.\n     */\n    function _getBeacon() internal view returns (address) {\n        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new beacon in the EIP1967 beacon slot.\n     */\n    function _setBeacon(address newBeacon) private {\n        require(AddressUpgradeable.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n        require(\n            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),\n            \"ERC1967: beacon implementation is not a contract\"\n        );\n        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n    }\n\n    /**\n     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n     *\n     * Emits a {BeaconUpgraded} event.\n     */\n    function _upgradeBeaconToAndCall(\n        address newBeacon,\n        bytes memory data,\n        bool forceCall\n    ) internal {\n        _setBeacon(newBeacon);\n        emit BeaconUpgraded(newBeacon);\n        if (data.length > 0 || forceCall) {\n            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);\n        }\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n        require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return AddressUpgradeable.verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"},{"file_path":"/AccessControlUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlUpgradeable.sol\";\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../utils/StringsUpgradeable.sol\";\nimport \"../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n *     require(hasRole(MY_ROLE, msg.sender));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\n    function __AccessControl_init() internal onlyInitializing {\n    }\n\n    function __AccessControl_init_unchained() internal onlyInitializing {\n    }\n    struct RoleData {\n        mapping(address => bool) members;\n        bytes32 adminRole;\n    }\n\n    mapping(bytes32 => RoleData) private _roles;\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with a standardized message including the required role.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     *\n     * _Available since v4.1._\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role);\n        _;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n        return _roles[role].members[account];\n    }\n\n    /**\n     * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n     * Overriding this function changes the behavior of the {onlyRole} modifier.\n     *\n     * Format of the revert message is described in {_checkRole}.\n     *\n     * _Available since v4.6._\n     */\n    function _checkRole(bytes32 role) internal view virtual {\n        _checkRole(role, _msgSender());\n    }\n\n    /**\n     * @dev Revert with a standard message if `account` is missing `role`.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     */\n    function _checkRole(bytes32 role, address account) internal view virtual {\n        if (!hasRole(role, account)) {\n            revert(\n                string(\n                    abi.encodePacked(\n                        \"AccessControl: account \",\n                        StringsUpgradeable.toHexString(uint160(account), 20),\n                        \" is missing role \",\n                        StringsUpgradeable.toHexString(uint256(role), 32)\n                    )\n                )\n            );\n        }\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n        return _roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function renounceRole(bytes32 role, address account) public virtual override {\n        require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event. Note that unlike {grantRole}, this function doesn't perform any\n     * checks on the calling account.\n     *\n     * May emit a {RoleGranted} event.\n     *\n     * [WARNING]\n     * ====\n     * This function should only be called from the constructor when setting\n     * up the initial roles for the system.\n     *\n     * Using this function in any other way is effectively circumventing the admin\n     * system imposed by {AccessControl}.\n     * ====\n     *\n     * NOTE: This function is deprecated in favor of {_grantRole}.\n     */\n    function _setupRole(bytes32 role, address account) internal virtual {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        bytes32 previousAdminRole = getRoleAdmin(role);\n        _roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function _grantRole(bytes32 role, address account) internal virtual {\n        if (!hasRole(role, account)) {\n            _roles[role].members[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual {\n        if (hasRole(role, account)) {\n            _roles[role].members[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"},{"file_path":"/Auth.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"../interfaces/IMain.sol\";\n\nuint256 constant LONG_FREEZE_CHARGES = 6; // 6 uses\nuint48 constant MAX_UNFREEZE_AT = type(uint48).max;\nuint48 constant MAX_SHORT_FREEZE = 2592000; // 1 month\nuint48 constant MAX_LONG_FREEZE = 31536000; // 1 year\n\n/**\n * @title Auth\n * @notice Provides fine-grained access controls and exports frozen/paused states to Components.\n */\nabstract contract Auth is AccessControlUpgradeable, IAuth {\n    /**\n     * System-wide states (does not impact ERC20 functions)\n     *  - Frozen: only allow OWNER actions and staking\n     *  - Paused: only allow OWNER actions, redemption, staking, and rewards payout\n     *\n     * Typically freezing thaws on its own in a predetemined number of blocks.\n     *   However, OWNER can also freeze forever.\n     */\n\n    /// The rest of the contract uses the shorthand; these declarations are here for getters\n    bytes32 public constant OWNER_ROLE = OWNER;\n    bytes32 public constant SHORT_FREEZER_ROLE = SHORT_FREEZER;\n    bytes32 public constant LONG_FREEZER_ROLE = LONG_FREEZER;\n    bytes32 public constant PAUSER_ROLE = PAUSER;\n\n    // === Freezing ===\n\n    mapping(address => uint256) public longFreezes;\n\n    uint48 public unfreezeAt; // {s} uint48.max to pause indefinitely\n    uint48 public shortFreeze; // {s} length of an initial freeze\n    uint48 public longFreeze; // {s} length of a freeze extension\n\n    // === Pausing ===\n\n    bool public paused;\n\n    /* ==== Invariants ====\n       0 <= longFreeze[a] <= LONG_FREEZE_CHARGES for all addrs a\n       set{a has LONG_FREEZER} == set{a : longFreeze[a] == 0}\n    */\n\n    // checks:\n    // - __Auth_init has not previously been called\n    // - 0 < shortFreeze_ <= MAX_SHORT_FREEZE\n    // - 0 < longFreeze_ <= MAX_LONG_FREEZE\n    // effects:\n    // - caller has all roles\n    // - OWNER is the admin role for all roles\n    // - longFreezes[caller] == LONG_FREEZE_CHARGES\n    // - shortFreeze' == shortFreeze_\n    // - longFreeze' == longFreeze_\n    // questions: (what do I know about the values of paused and unfreezeAt?)\n    // untestable:\n    //      `else` branch of `onlyInitializing` (ie. revert) is currently untestable.\n    //      This function is only called inside other `init` functions, each of which is wrapped\n    //      in an `initializer` modifier, which would fail first.\n    // solhint-disable-next-line func-name-mixedcase\n    function __Auth_init(uint48 shortFreeze_, uint48 longFreeze_) internal onlyInitializing {\n        __AccessControl_init();\n\n        // Role setup\n        _setRoleAdmin(OWNER, OWNER);\n        _setRoleAdmin(SHORT_FREEZER, OWNER);\n        _setRoleAdmin(LONG_FREEZER, OWNER);\n        _setRoleAdmin(PAUSER, OWNER);\n\n        address msgSender = _msgSender();\n        _grantRole(OWNER, msgSender);\n        _grantRole(SHORT_FREEZER, msgSender);\n        _grantRole(LONG_FREEZER, msgSender);\n        _grantRole(PAUSER, msgSender);\n        longFreezes[msgSender] = LONG_FREEZE_CHARGES;\n\n        setShortFreeze(shortFreeze_);\n        setLongFreeze(longFreeze_);\n    }\n\n    // checks: caller is an admin for role, account is not 0\n    // effects:\n    // - account has the `role` role\n    // - if role is LONG_FREEZER, then longFreezes'[account] == LONG_FREEZE_CHARGES\n    function grantRole(bytes32 role, address account)\n        public\n        override(AccessControlUpgradeable, IAccessControlUpgradeable)\n        onlyRole(getRoleAdmin(role))\n    {\n        require(account != address(0), \"cannot grant role to address 0\");\n        if (role == LONG_FREEZER) longFreezes[account] = LONG_FREEZE_CHARGES;\n        _grantRole(role, account);\n    }\n\n    // ==== System-wide views ====\n    // returns: bool(main is frozen) == now < unfreezeAt\n    function frozen() external view returns (bool) {\n        return block.timestamp < unfreezeAt;\n    }\n\n    /// @dev This -or- condition is a performance optimization for the consuming Component\n    // returns: bool(main is frozen or paused) == paused || (now < unfreezeAt)\n    function pausedOrFrozen() public view returns (bool) {\n        return paused || block.timestamp < unfreezeAt;\n    }\n\n    // === Freezing ===\n\n    /// Enter a freeze for the `shortFreeze` duration\n    // checks:\n    // - caller has the SHORT_FREEZER role\n    // - now + shortFreeze >= unfreezeAt (that is, this call should increase unfreezeAt)\n    // effects:\n    // - unfreezeAt' = now + shortFreeze\n    // - after, caller does not have the SHORT_FREEZER role\n    function freezeShort() external onlyRole(SHORT_FREEZER) {\n        // Revoke short freezer role after one use\n        _revokeRole(SHORT_FREEZER, _msgSender());\n        freezeUntil(uint48(block.timestamp) + shortFreeze);\n    }\n\n    /// Enter a freeze by the `longFreeze` duration\n    // checks:\n    // - caller has the LONG_FREEZER role\n    // - longFreezes[caller] > 0\n    // - now + longFreeze >= unfreezeAt (that is, this call should increase unfreezeAt)\n    // effects:\n    // - unfreezeAt' = now + longFreeze\n    // - longFreezes'[caller] = longFreezes[caller] - 1\n    // - if longFreezes'[caller] == 0 then caller loses the LONG_FREEZER role\n    function freezeLong() external onlyRole(LONG_FREEZER) {\n        longFreezes[_msgSender()] -= 1; // reverts on underflow\n\n        // Revoke on 0 charges as a cleanup step\n        if (longFreezes[_msgSender()] == 0) _revokeRole(LONG_FREEZER, _msgSender());\n        freezeUntil(uint48(block.timestamp) + longFreeze);\n    }\n\n    /// Enter a permanent freeze\n    // checks:\n    // - caller has the OWNER role\n    // - unfreezeAt != type(uint48).max\n    // effects: unfreezeAt' = type(uint48).max\n    function freezeForever() external onlyRole(OWNER) {\n        freezeUntil(MAX_UNFREEZE_AT);\n    }\n\n    /// End all freezes\n    // checks:\n    // - unfreezeAt > now  (i.e, frozen() == true before the call)\n    // - caller has the OWNER role\n    // effects: unfreezeAt' = now  (i.e, frozen() == false after the call)\n    function unfreeze() external onlyRole(OWNER) {\n        emit UnfreezeAtSet(unfreezeAt, uint48(block.timestamp));\n        unfreezeAt = uint48(block.timestamp);\n    }\n\n    // === Pausing ===\n    // checks: caller has PAUSER\n    // effects: paused' = true\n    function pause() external onlyRole(PAUSER) {\n        emit PausedSet(paused, true);\n        paused = true;\n    }\n\n    // checks: caller has PAUSER\n    // effects: paused' = false\n    function unpause() external onlyRole(PAUSER) {\n        emit PausedSet(paused, false);\n        paused = false;\n    }\n\n    // === Gov params ===\n\n    /// @custom:governance\n    function setShortFreeze(uint48 shortFreeze_) public onlyRole(OWNER) {\n        require(shortFreeze_ > 0 && shortFreeze_ <= MAX_SHORT_FREEZE, \"short freeze out of range\");\n        emit ShortFreezeDurationSet(shortFreeze, shortFreeze_);\n        shortFreeze = shortFreeze_;\n    }\n\n    /// @custom:governance\n    function setLongFreeze(uint48 longFreeze_) public onlyRole(OWNER) {\n        require(longFreeze_ > 0 && longFreeze_ <= MAX_LONG_FREEZE, \"long freeze out of range\");\n        emit LongFreezeDurationSet(longFreeze, longFreeze_);\n        longFreeze = longFreeze_;\n    }\n\n    // === Private Helper ===\n    // checks: newUnfreezeAt > unfreezeAt\n    // effects: unfreezeAt' = newUnfreezeAt\n    function freezeUntil(uint48 newUnfreezeAt) private {\n        require(newUnfreezeAt > unfreezeAt, \"frozen\");\n        emit UnfreezeAtSet(unfreezeAt, newUnfreezeAt);\n        unfreezeAt = newUnfreezeAt;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[48] private __gap;\n}\n"},{"file_path":"/IBackingManager.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./IComponent.sol\";\nimport \"./ITrading.sol\";\n\n/**\n * @title IBackingManager\n * @notice The BackingManager handles changes in the ERC20 balances that back an RToken.\n *   - It computes which trades to perform, if any, and initiates these trades with the Broker.\n *   - If already collateralized, excess assets are transferred to RevenueTraders.\n *\n * `manageTokens(erc20s)` and `manageTokensSortedOrder(erc20s)` are handles for getting at the\n *   same underlying functionality. The former allows an ERC20 list in any order, while the\n *   latter requires a sorted array, and executes in O(n) rather than O(n^2) time. In the\n *   vast majority of cases we expect the the O(n^2) function to be acceptable.\n */\ninterface IBackingManager is IComponent, ITrading {\n    event TradingDelaySet(uint48 indexed oldVal, uint48 indexed newVal);\n    event BackingBufferSet(uint192 indexed oldVal, uint192 indexed newVal);\n\n    // Initialization\n    function init(\n        IMain main_,\n        uint48 tradingDelay_,\n        uint192 backingBuffer_,\n        uint192 maxTradeSlippage_,\n        uint192 minTradeVolume_\n    ) external;\n\n    // Give RToken max allowance over a registered token\n    /// @custom:refresher\n    /// @custom:interaction\n    function grantRTokenAllowance(IERC20) external;\n\n    /// Maintain the overall backing policy; handout assets otherwise\n    /// @dev Performs a uniqueness check on the erc20s list in O(n^2)\n    /// @custom:interaction\n    function manageTokens(IERC20[] memory erc20s) external;\n\n    /// Maintain the overall backing policy; handout assets otherwise\n    /// @dev Tokens must be in sorted order!\n    /// @dev Performs a uniqueness check on the erc20s list in O(n)\n    /// @custom:interaction\n    function manageTokensSortedOrder(IERC20[] memory erc20s) external;\n}\n\ninterface TestIBackingManager is IBackingManager, TestITrading {\n    function tradingDelay() external view returns (uint48);\n\n    function backingBuffer() external view returns (uint192);\n\n    function setTradingDelay(uint48 val) external;\n\n    function setBackingBuffer(uint192 val) external;\n}\n"},{"file_path":"/StorageSlotUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlotUpgradeable {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n}\n"},{"file_path":"/extensions/draft-IERC20PermitUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"},{"file_path":"/UUPSUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../ERC1967/ERC1967UpgradeUpgradeable.sol\";\nimport \"./Initializable.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {\n    function __UUPSUpgradeable_init() internal onlyInitializing {\n    }\n\n    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\n    }\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n    address private immutable __self = address(this);\n\n    /**\n     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case\n     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n     * fail.\n     */\n    modifier onlyProxy() {\n        require(address(this) != __self, \"Function must be called through delegatecall\");\n        require(_getImplementation() == __self, \"Function must be called through active proxy\");\n        _;\n    }\n\n    /**\n     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n     * callable on the implementing contract but not through proxies.\n     */\n    modifier notDelegated() {\n        require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n        _;\n    }\n\n    /**\n     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the\n     * implementation. It is used to validate that the this implementation remains valid after an upgrade.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.\n     */\n    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {\n        return _IMPLEMENTATION_SLOT;\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy to `newImplementation`.\n     *\n     * Calls {_authorizeUpgrade}.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function upgradeTo(address newImplementation) external virtual onlyProxy {\n        _authorizeUpgrade(newImplementation);\n        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n     * encoded in `data`.\n     *\n     * Calls {_authorizeUpgrade}.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {\n        _authorizeUpgrade(newImplementation);\n        _upgradeToAndCallUUPS(newImplementation, data, true);\n    }\n\n    /**\n     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n     * {upgradeTo} and {upgradeToAndCall}.\n     *\n     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n     *\n     * ```solidity\n     * function _authorizeUpgrade(address) internal override onlyOwner {}\n     * ```\n     */\n    function _authorizeUpgrade(address newImplementation) internal virtual;\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"},{"file_path":"/Initializable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n     * initialization step. This is essential to configure modules that are added through upgrades and that require\n     * initialization.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized < type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n}\n"},{"file_path":"/IAccessControlUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControlUpgradeable {\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"},{"file_path":"/StringsUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n    bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        // Inspired by OraclizeAPI's implementation - MIT licence\n        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n        if (value == 0) {\n            return \"0\";\n        }\n        uint256 temp = value;\n        uint256 digits;\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n        bytes memory buffer = new bytes(digits);\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return \"0x00\";\n        }\n        uint256 temp = value;\n        uint256 length = 0;\n        while (temp != 0) {\n            length++;\n            temp >>= 8;\n        }\n        return toHexString(value, length);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _HEX_SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n}\n"},{"file_path":"/IERC165Upgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},{"file_path":"/draft-IERC1822Upgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822ProxiableUpgradeable {\n    /**\n     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n     * address.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy.\n     */\n    function proxiableUUID() external view returns (bytes32);\n}\n"},{"file_path":"/ComponentRegistry.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../interfaces/IMain.sol\";\nimport \"./Auth.sol\";\n\n/**\n * @title ComponentRegistry\n */\nabstract contract ComponentRegistry is Initializable, Auth, IComponentRegistry {\n    // untestable:\n    //      `else` branch of `onlyInitializing` (ie. revert) is currently untestable.\n    //      This function is only called inside other `init` functions, each of which is wrapped\n    //      in an `initializer` modifier, which would fail first.\n    // solhint-disable-next-line func-name-mixedcase\n    function __ComponentRegistry_init(Components memory components_) internal onlyInitializing {\n        _setBackingManager(components_.backingManager);\n        _setBasketHandler(components_.basketHandler);\n        _setRSRTrader(components_.rsrTrader);\n        _setRTokenTrader(components_.rTokenTrader);\n        _setAssetRegistry(components_.assetRegistry);\n        _setDistributor(components_.distributor);\n        _setFurnace(components_.furnace);\n        _setBroker(components_.broker);\n        _setStRSR(components_.stRSR);\n        _setRToken(components_.rToken);\n    }\n\n    // === Components ===\n\n    IRToken public rToken;\n\n    function _setRToken(IRToken val) private {\n        require(address(val) != address(0), \"invalid RToken address\");\n        emit RTokenSet(rToken, val);\n        rToken = val;\n    }\n\n    IStRSR public stRSR;\n\n    function _setStRSR(IStRSR val) private {\n        require(address(val) != address(0), \"invalid StRSR address\");\n        emit StRSRSet(stRSR, val);\n        stRSR = val;\n    }\n\n    IAssetRegistry public assetRegistry;\n\n    function _setAssetRegistry(IAssetRegistry val) private {\n        require(address(val) != address(0), \"invalid AssetRegistry address\");\n        emit AssetRegistrySet(assetRegistry, val);\n        assetRegistry = val;\n    }\n\n    IBasketHandler public basketHandler;\n\n    function _setBasketHandler(IBasketHandler val) private {\n        require(address(val) != address(0), \"invalid BasketHandler address\");\n        emit BasketHandlerSet(basketHandler, val);\n        basketHandler = val;\n    }\n\n    IBackingManager public backingManager;\n\n    function _setBackingManager(IBackingManager val) private {\n        require(address(val) != address(0), \"invalid BackingManager address\");\n        emit BackingManagerSet(backingManager, val);\n        backingManager = val;\n    }\n\n    IDistributor public distributor;\n\n    function _setDistributor(IDistributor val) private {\n        require(address(val) != address(0), \"invalid Distributor address\");\n        emit DistributorSet(distributor, val);\n        distributor = val;\n    }\n\n    IRevenueTrader public rsrTrader;\n\n    function _setRSRTrader(IRevenueTrader val) private {\n        require(address(val) != address(0), \"invalid RSRTrader address\");\n        emit RSRTraderSet(rsrTrader, val);\n        rsrTrader = val;\n    }\n\n    IRevenueTrader public rTokenTrader;\n\n    function _setRTokenTrader(IRevenueTrader val) private {\n        require(address(val) != address(0), \"invalid RTokenTrader address\");\n        emit RTokenTraderSet(rTokenTrader, val);\n        rTokenTrader = val;\n    }\n\n    IFurnace public furnace;\n\n    function _setFurnace(IFurnace val) private {\n        require(address(val) != address(0), \"invalid Furnace address\");\n        emit FurnaceSet(furnace, val);\n        furnace = val;\n    }\n\n    IBroker public broker;\n\n    function _setBroker(IBroker val) private {\n        require(address(val) != address(0), \"invalid Broker address\");\n        emit BrokerSet(broker, val);\n        broker = val;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[40] private __gap;\n}\n"},{"file_path":"/interfaces/AggregatorV3Interface.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n  function decimals() external view returns (uint8);\n\n  function description() external view returns (string memory);\n\n  function version() external view returns (uint256);\n\n  // getRoundData and latestRoundData should both raise \"No data present\"\n  // if they do not have data to report, instead of returning unset values\n  // which could be misinterpreted as actual reported values.\n  function getRoundData(uint80 _roundId)\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n\n  function latestRoundData()\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n}\n"},{"file_path":"/Throttle.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"./Fixed.sol\";\n\nuint48 constant ONE_HOUR = 3600; // {seconds/hour}\n\n/**\n * @title ThrottleLib\n * A library that implements a usage throttle that can be used to ensure net issuance\n * or net redemption for an RToken never exceeds some bounds per unit time (hour).\n *\n * It is expected for the RToken to use this library with two instances, one for issuance\n * and one for redemption. Issuance causes the available redemption amount to increase, and\n * visa versa.\n */\nlibrary ThrottleLib {\n    using FixLib for uint192;\n\n    struct Params {\n        uint256 amtRate; // {qRTok/hour} a quantity of RToken hourly; cannot be 0\n        uint192 pctRate; // {1/hour} a fraction of RToken hourly; can be 0\n    }\n\n    struct Throttle {\n        // === Gov params ===\n        Params params;\n        // === Cache ===\n        uint48 lastTimestamp; // {seconds}\n        uint256 lastAvailable; // {qRTok}\n    }\n\n    /// Reverts if usage amount exceeds available amount\n    /// @param supply {qRTok} Total RToken supply beforehand\n    /// @param amount {qRTok} Amount of RToken to use. Should be negative for the issuance\n    ///   throttle during redemption and for the redemption throttle during issuance.\n    function useAvailable(\n        Throttle storage throttle,\n        uint256 supply,\n        int256 amount\n    ) internal {\n        // untestable: amtRate will always be greater > 0 due to previous validations\n        if (throttle.params.amtRate == 0 && throttle.params.pctRate == 0) return;\n\n        // Calculate hourly limit\n        uint256 limit = hourlyLimit(throttle, supply); // {qRTok}\n\n        // Calculate available amount before supply change\n        uint256 available = currentlyAvailable(throttle, limit);\n\n        // Calculate available amount after supply change\n        if (amount > 0) {\n            require(uint256(amount) <= available, \"supply change throttled\");\n            available -= uint256(amount);\n            // untestable: the final else statement, amount will never be 0\n        } else if (amount < 0) {\n            available += uint256(-amount);\n        }\n\n        // Update cached values\n        throttle.lastAvailable = available;\n        throttle.lastTimestamp = uint48(block.timestamp);\n    }\n\n    /// @param limit {qRTok/hour} The hourly limit\n    /// @return available {qRTok} Amount currently available for consumption\n    function currentlyAvailable(Throttle storage throttle, uint256 limit)\n        internal\n        view\n        returns (uint256 available)\n    {\n        uint48 delta = uint48(block.timestamp) - throttle.lastTimestamp; // {seconds}\n        available = throttle.lastAvailable + (limit * delta) / ONE_HOUR;\n        if (available > limit) available = limit;\n    }\n\n    /// @return limit {qRTok} The hourly limit\n    function hourlyLimit(Throttle storage throttle, uint256 supply)\n        internal\n        view\n        returns (uint256 limit)\n    {\n        Params storage params = throttle.params;\n\n        // Calculate hourly limit as: max(params.amtRate, supply.mul(params.pctRate))\n        limit = (supply * params.pctRate) / FIX_ONE_256; // {qRTok}\n        if (params.amtRate > limit) limit = params.amtRate;\n    }\n}\n"},{"file_path":"/IRevenueTrader.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"./IComponent.sol\";\nimport \"./ITrading.sol\";\n\n/**\n * @title IRevenueTrader\n * @notice The RevenueTrader is an extension of the trading mixin that trades all\n *   assets at its address for a single target asset. There are two runtime instances\n *   of the RevenueTrader, 1 for RToken and 1 for RSR.\n */\ninterface IRevenueTrader is IComponent, ITrading {\n    // Initialization\n    function init(\n        IMain main_,\n        IERC20 tokenToBuy_,\n        uint192 maxTradeSlippage_,\n        uint192 minTradeVolume_\n    ) external;\n\n    /// Processes a single token; unpermissioned\n    /// @dev Intended to be used with multicall\n    /// @custom:interaction\n    function manageToken(IERC20 sell) external;\n}\n\n// solhint-disable-next-line no-empty-blocks\ninterface TestIRevenueTrader is IRevenueTrader, TestITrading {\n    function tokenToBuy() external view returns (IERC20);\n}\n"},{"file_path":"/IDistributor.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./IComponent.sol\";\n\nstruct RevenueShare {\n    uint16 rTokenDist; // {revShare} A value between [0, 10,000]\n    uint16 rsrDist; // {revShare} A value between [0, 10,000]\n}\n\n/// Assumes no more than 1024 independent distributions.\nstruct RevenueTotals {\n    uint24 rTokenTotal; // {revShare}\n    uint24 rsrTotal; // {revShare}\n}\n\n/**\n * @title IDistributor\n * @notice The Distributor Component maintains a revenue distribution table that dictates\n *   how to divide revenue across the Furnace, StRSR, and any other destinations.\n */\ninterface IDistributor is IComponent {\n    /// Emitted when a distribution is set\n    /// @param dest The address set to receive the distribution\n    /// @param rTokenDist The distribution of RToken that should go to `dest`\n    /// @param rsrDist The distribution of RSR that should go to `dest`\n    event DistributionSet(address dest, uint16 rTokenDist, uint16 rsrDist);\n\n    /// Emitted when revenue is distributed\n    /// @param erc20 The token being distributed, either RSR or the RToken itself\n    /// @param source The address providing the revenue\n    /// @param amount The amount of the revenue\n    event RevenueDistributed(IERC20 indexed erc20, address indexed source, uint256 indexed amount);\n\n    // Initialization\n    function init(IMain main_, RevenueShare memory dist) external;\n\n    /// @custom:governance\n    function setDistribution(address dest, RevenueShare memory share) external;\n\n    /// Distribute the `erc20` token across all revenue destinations\n    /// @custom:interaction\n    function distribute(IERC20 erc20, uint256 amount) external;\n\n    /// @return revTotals The total of all  destinations\n    function totals() external view returns (RevenueTotals memory revTotals);\n}\n\ninterface TestIDistributor is IDistributor {\n    // solhint-disable-next-line func-name-mixedcase\n    function FURNACE() external view returns (address);\n\n    // solhint-disable-next-line func-name-mixedcase\n    function ST_RSR() external view returns (address);\n\n    /// @return rTokenDist The RToken distribution for the address\n    /// @return rsrDist The RSR distribution for the address\n    function distribution(address) external view returns (uint16 rTokenDist, uint16 rsrDist);\n}\n"},{"file_path":"/ITrade.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * Simple generalized trading interface for all Trade contracts to obey\n *\n * Usage: if (canSettle()) settle()\n */\ninterface ITrade {\n    function sell() external view returns (IERC20Metadata);\n\n    function buy() external view returns (IERC20Metadata);\n\n    /// @return The timestamp at which the trade is projected to become settle-able\n    function endTime() external view returns (uint48);\n\n    /// @return True if the trade can be settled\n    /// @dev Should be guaranteed to be true eventually as an invariant\n    function canSettle() external view returns (bool);\n\n    /// Complete the trade and transfer tokens back to the origin trader\n    /// @return soldAmt {qSellTok} The quantity of tokens sold\n    /// @return boughtAmt {qBuyTok} The quantity of tokens bought\n    function settle() external returns (uint256 soldAmt, uint256 boughtAmt);\n}\n"},{"file_path":"/IComponent.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"./IMain.sol\";\nimport \"./IVersioned.sol\";\n\n/**\n * @title IComponent\n * @notice A Component is the central building block of all our system contracts. Components\n *   contain important state that must be migrated during upgrades, and they delegate\n *   their ownership to Main's owner.\n */\ninterface IComponent is IVersioned {\n    function main() external view returns (IMain);\n}\n"},{"file_path":"/IBeaconUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeaconUpgradeable {\n    /**\n     * @dev Must return an address that can be used as a delegate call target.\n     *\n     * {BeaconProxy} will check that this address is a contract.\n     */\n    function implementation() external view returns (address);\n}\n"},{"file_path":"/IBasketHandler.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../libraries/Fixed.sol\";\nimport \"./IAsset.sol\";\nimport \"./IComponent.sol\";\n\nstruct BasketRange {\n    uint192 bottom; // {BU}\n    uint192 top; // {BU}\n}\n\n/**\n * @title IBasketHandler\n * @notice The BasketHandler aims to maintain a reference basket of constant target unit amounts.\n * When a collateral token defaults, a new reference basket of equal target units is set.\n * When _all_ collateral tokens default for a target unit, only then is the basket allowed to fall\n *   in terms of target unit amounts. The basket is considered defaulted in this case.\n */\ninterface IBasketHandler is IComponent {\n    /// Emitted when the prime basket is set\n    /// @param erc20s The collateral tokens for the prime basket\n    /// @param targetAmts {target/BU} A list of quantities of target unit per basket unit\n    /// @param targetNames Each collateral token's targetName\n    event PrimeBasketSet(IERC20[] erc20s, uint192[] targetAmts, bytes32[] targetNames);\n\n    /// Emitted when the reference basket is set\n    /// @param nonce The basket nonce\n    /// @param erc20s The list of collateral tokens in the reference basket\n    /// @param refAmts {ref/BU} The reference amounts of the basket collateral tokens\n    /// @param disabled True when the list of erc20s + refAmts may not be correct\n    event BasketSet(uint256 indexed nonce, IERC20[] erc20s, uint192[] refAmts, bool disabled);\n\n    /// Emitted when a backup config is set for a target unit\n    /// @param targetName The name of the target unit as a bytes32\n    /// @param max The max number to use from `erc20s`\n    /// @param erc20s The set of backup collateral tokens\n    event BackupConfigSet(bytes32 indexed targetName, uint256 indexed max, IERC20[] erc20s);\n\n    // Initialization\n    function init(IMain main_) external;\n\n    /// Set the prime basket\n    /// @param erc20s The collateral tokens for the new prime basket\n    /// @param targetAmts The target amounts (in) {target/BU} for the new prime basket\n    ///                   required range: 1e9 values; absolute range irrelevant.\n    /// @custom:governance\n    function setPrimeBasket(IERC20[] memory erc20s, uint192[] memory targetAmts) external;\n\n    /// Set the backup configuration for a given target\n    /// @param targetName The name of the target as a bytes32\n    /// @param max The maximum number of collateral tokens to use from this target\n    ///            Required range: 1-255\n    /// @param erc20s A list of ordered backup collateral tokens\n    /// @custom:governance\n    function setBackupConfig(\n        bytes32 targetName,\n        uint256 max,\n        IERC20[] calldata erc20s\n    ) external;\n\n    /// Default the basket in order to schedule a basket refresh\n    /// @custom:protected\n    function disableBasket() external;\n\n    /// Governance-controlled setter to cause a basket switch explicitly\n    /// @custom:governance\n    /// @custom:interaction\n    function refreshBasket() external;\n\n    /// @return If the BackingManager has sufficient collateral to redeem the entire RToken supply\n    function fullyCollateralized() external view returns (bool);\n\n    /// @return status The worst CollateralStatus of all collateral in the basket\n    function status() external view returns (CollateralStatus status);\n\n    /// @param erc20 The ERC20 token contract for the asset\n    /// @return {tok/BU} The whole token quantity of token in the reference basket\n    /// Returns 0 if erc20 is not registered or not in the basket\n    /// Returns FIX_MAX (in lieu of +infinity) if Collateral.refPerTok() is 0.\n    /// Otherwise, returns (token's basket.refAmts / token's Collateral.refPerTok())\n    function quantity(IERC20 erc20) external view returns (uint192);\n\n    /// Like quantity(), but unsafe because it DOES NOT CONFIRM THAT THE ASSET IS CORRECT\n    /// @param erc20 The ERC20 token contract for the asset\n    /// @param asset The registered asset plugin contract for the erc20\n    /// @return {tok/BU} The whole token quantity of token in the reference basket\n    /// Returns 0 if erc20 is not registered or not in the basket\n    /// Returns FIX_MAX (in lieu of +infinity) if Collateral.refPerTok() is 0.\n    /// Otherwise, returns (token's basket.refAmts / token's Collateral.refPerTok())\n    function quantityUnsafe(IERC20 erc20, IAsset asset) external view returns (uint192);\n\n    /// @param amount {BU}\n    /// @return erc20s The addresses of the ERC20 tokens in the reference basket\n    /// @return quantities {qTok} The quantity of each ERC20 token to issue `amount` baskets\n    function quote(uint192 amount, RoundingMode rounding)\n        external\n        view\n        returns (address[] memory erc20s, uint256[] memory quantities);\n\n    /// @return top {BU} The number of partial basket units: e.g max(coll.map((c) => c.balAsBUs())\n    ///         bottom {BU} The number of whole basket units held by the account\n    function basketsHeldBy(address account) external view returns (BasketRange memory);\n\n    /// Should not revert\n    /// @return low {UoA/BU} The lower end of the price estimate\n    /// @return high {UoA/BU} The upper end of the price estimate\n    function price() external view returns (uint192 low, uint192 high);\n\n    /// Should not revert\n    /// lotLow should be nonzero if a BU could be worth selling\n    /// @return lotLow {UoA/tok} The lower end of the lot price estimate\n    /// @return lotHigh {UoA/tok} The upper end of the lot price estimate\n    function lotPrice() external view returns (uint192 lotLow, uint192 lotHigh);\n\n    /// @return timestamp The timestamp at which the basket was last set\n    function timestamp() external view returns (uint48);\n\n    /// @return The current basket nonce, regardless of status\n    function nonce() external view returns (uint48);\n}\n"},{"file_path":"/Versioned.sol","source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"../interfaces/IVersioned.sol\";\n\n// This value should be updated on each release\nstring constant VERSION = \"2.0.0\";\n\n/**\n * @title Versioned\n * @notice A mix-in to track semantic versioning uniformly across contracts.\n */\nabstract contract Versioned is IVersioned {\n    function version() public pure virtual override returns (string memory) {\n        return VERSION;\n    }\n}\n"}],"can_be_visualized_via_sol2uml":false,"compiler_settings":{"compilationTarget":{"contracts/p1/Main.sol":"MainP1"},"evmVersion":"london","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":true,"runs":200},"remappings":[]},"compiler_version":"v0.8.17+commit.8df45f5f","constructor_args":null,"creation_bytecode":"0x60a0604052306080523480156200001557600080fd5b50600054610100900460ff1615808015620000375750600054600160ff909116105b8062000067575062000054306200014160201b6200152d1760201c565b15801562000067575060005460ff166001145b620000cf5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff191660011790558015620000f3576000805461ff0019166101001790555b80156200013a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5062000150565b6001600160a01b03163b151590565b608051612cd56200018860003960008181610b8b01528181610bcb01528181610ce301528181610d230152610ebd0152612cd56000f3fe60806040526004361061025c5760003560e01c80635c975abb11610144578063bfe10928116100b6578063e083b5e61161007a578063e083b5e614610704578063e58378bb14610731578063e63ab1e914610746578063f17063751461075b578063f8aa0c4e14610770578063fe8aa12a1461079657600080fd5b8063bfe1092814610663578063c99dc3dd14610683578063d547741f146106a4578063dc8af5f6146106c4578063de1611cf146106e457600080fd5b806391d148541161010857806391d14854146105b957806394c7f299146105d9578063979d7e86146105ee578063992e1d6a1461060e578063a217fddf1461062e578063abff01101461064357600080fd5b80635c975abb1461052f578063656e96e1146105505780636a28f00014610570578063705a6618146105855780638456cb59146105a457600080fd5b80633659cfe6116101dd5780634f1ef286116101a15780634f1ef2861461047e5780635187ae681461049157806352d1902d146104b157806353136763146104c657806354fd4d50146104e6578063590f6b1a1461051a57600080fd5b80633659cfe6146103e95780633f4ba83a1461040957806340c65f721461041e57806341bf0c4e1461043e5780634780a5e51461045e57600080fd5b80632b56d18a116102245780632b56d18a1461031f5780632d8709601461035c5780632f2439b1146103715780632f2ff15d146103a957806336568abe146103c957600080fd5b806301ffc9a714610261578063054f7d9c146102965780630f702ed3146102b557806318178358146102cc578063248a9ca3146102e1575b600080fd5b34801561026d57600080fd5b5061028161027c366004612696565b6107ab565b60405190151581526020015b60405180910390f35b3480156102a257600080fd5b5060985465ffffffffffff164210610281565b3480156102c157600080fd5b506102ca6107e2565b005b3480156102d857600080fd5b506102ca61087a565b3480156102ed57600080fd5b506103116102fc3660046126c0565b60009081526065602052604090206001015490565b60405190815260200161028d565b34801561032b57600080fd5b5060985461034590600160301b900465ffffffffffff1681565b60405165ffffffffffff909116815260200161028d565b34801561036857600080fd5b50610311610a01565b34801561037d57600080fd5b5060cc54610391906001600160a01b031681565b6040516001600160a01b03909116815260200161028d565b3480156103b557600080fd5b506102ca6103c43660046126ee565b610a32565b3480156103d557600080fd5b506102ca6103e43660046126ee565b610b03565b3480156103f557600080fd5b506102ca61040436600461271e565b610b81565b34801561041557600080fd5b506102ca610c5d565b34801561042a57600080fd5b5060c954610391906001600160a01b031681565b34801561044a57600080fd5b5060d054610391906001600160a01b031681565b34801561046a57600080fd5b5060ca54610391906001600160a01b031681565b6102ca61048c3660046127ac565b610cd9565b34801561049d57600080fd5b506102ca6104ac36600461286f565b610da5565b3480156104bd57600080fd5b50610311610eb0565b3480156104d257600080fd5b5060cf54610391906001600160a01b031681565b3480156104f257600080fd5b5060408051808201825260058152640322e302e360dc1b6020820152905161028d91906128ae565b34801561052657600080fd5b50610311610f63565b34801561053b57600080fd5b5060985461028190600160901b900460ff1681565b34801561055c57600080fd5b5060d154610391906001600160a01b031681565b34801561057c57600080fd5b506102ca610f92565b34801561059157600080fd5b506098546103459065ffffffffffff1681565b3480156105b057600080fd5b506102ca611017565b3480156105c557600080fd5b506102816105d43660046126ee565b61109a565b3480156105e557600080fd5b506102ca6110c8565b3480156105fa57600080fd5b5060cb54610391906001600160a01b031681565b34801561061a57600080fd5b506102ca6106293660046128ec565b611107565b34801561063a57600080fd5b50610311600081565b34801561064f57600080fd5b5060d254610391906001600160a01b031681565b34801561066f57600080fd5b5060ce54610391906001600160a01b031681565b34801561068f57600080fd5b5061015f54610391906001600160a01b031681565b3480156106b057600080fd5b506102ca6106bf3660046126ee565b6112c0565b3480156106d057600080fd5b5060cd54610391906001600160a01b031681565b3480156106f057600080fd5b506102ca6106ff36600461286f565b6112e5565b34801561071057600080fd5b5061031161071f36600461271e565b60976020526000908152604090205481565b34801561073d57600080fd5b506103116113f2565b34801561075257600080fd5b50610311611419565b34801561076757600080fd5b50610281611441565b34801561077c57600080fd5b5060985461034590600160601b900465ffffffffffff1681565b3480156107a257600080fd5b506102ca61146a565b60006001600160e01b03198216637965db0b60e01b14806107dc57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b815250610811906129fe565b61081a8161153c565b6108526040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b81525061084c906129fe565b33611546565b6098546108779061087290600160301b900465ffffffffffff1642612a3b565b6115ad565b50565b60cb60009054906101000a90046001600160a01b03166001600160a01b031663f8ac93e86040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156108ca57600080fd5b505af11580156108de573d6000803e3d6000fd5b505050506108ea611441565b1561092f5760405162461bcd60e51b815260206004820152601060248201526f3830bab9b2b21037b910333937bd32b760811b60448201526064015b60405180910390fd5b60d160009054906101000a90046001600160a01b03166001600160a01b0316635220f5106040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561097f57600080fd5b505af1158015610993573d6000803e3d6000fd5b5050505060ca60009054906101000a90046001600160a01b03166001600160a01b031663296130866040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156109e757600080fd5b505af11580156109fb573d6000803e3d6000fd5b50505050565b6040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b815250610a2f906129fe565b81565b600082815260656020526040902060010154610a4d8161153c565b6001600160a01b038216610aa35760405162461bcd60e51b815260206004820152601e60248201527f63616e6e6f74206772616e7420726f6c6520746f2061646472657373203000006044820152606401610926565b6040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b815250610ad1906129fe565b8303610af4576001600160a01b0382166000908152609760205260409020600690555b610afe838361164c565b505050565b6001600160a01b0381163314610b735760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610926565b610b7d8282611546565b5050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610bc95760405162461bcd60e51b815260040161092690612a61565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610c12600080516020612c59833981519152546001600160a01b031690565b6001600160a01b031614610c385760405162461bcd60e51b815260040161092690612aad565b610c41816116d2565b6040805160008082526020820190925261087791839190611702565b604051806040016040528060068152602001652820aaa9a2a960d11b815250610c85906129fe565b610c8e8161153c565b609854604051600091600160901b900460ff161515907f8a03df86592b6c04a66160b441f1d7282689edca334882d14f468dc60352b0ff908390a3506098805460ff60901b19169055565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610d215760405162461bcd60e51b815260040161092690612a61565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610d6a600080516020612c59833981519152546001600160a01b031690565b6001600160a01b031614610d905760405162461bcd60e51b815260040161092690612aad565b610d99826116d2565b610b7d82826001611702565b6040518060400160405280600581526020016427aba722a960d91b815250610dcc906129fe565b610dd58161153c565b60008265ffffffffffff16118015610df957506301e1338065ffffffffffff831611155b610e455760405162461bcd60e51b815260206004820152601860248201527f6c6f6e6720667265657a65206f7574206f662072616e676500000000000000006044820152606401610926565b60985460405165ffffffffffff80851692600160601b900416907f2b855a9093ce8fb8bd37179aa306b424a5008d3a000751f4c2e721c51b89f9a290600090a3506098805465ffffffffffff909216600160601b0265ffffffffffff60601b19909216919091179055565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610f505760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610926565b50600080516020612c5983398151915290565b6040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b815250610a2f906129fe565b6040518060400160405280600581526020016427aba722a960d91b815250610fb9906129fe565b610fc28161153c565b60985460405165ffffffffffff4281169216907f4fd793fe252ef26ede0a814ca52971990ff5ade10f86376fb1914bfb17c57e0890600090a3506098805465ffffffffffff19164265ffffffffffff16179055565b604051806040016040528060068152602001652820aaa9a2a960d11b81525061103f906129fe565b6110488161153c565b609854604051600191600160901b900460ff161515907f8a03df86592b6c04a66160b441f1d7282689edca334882d14f468dc60352b0ff90600090a3506098805460ff60901b1916600160901b179055565b60008281526065602090815260408083206001600160a01b038516845290915281205460ff165b9392505050565b6040518060400160405280600581526020016427aba722a960d91b8152506110ef906129fe565b6110f88161153c565b61087765ffffffffffff6115ad565b600054610100900460ff16158080156111275750600054600160ff909116105b806111415750303b158015611141575060005460ff166001145b6111a45760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610926565b6000805460ff1916600117905580156111c7576000805461ff0019166101001790555b6001600160a01b0384166112135760405162461bcd60e51b8152602060048201526013602482015272696e76616c696420525352206164647265737360681b6044820152606401610926565b61121d838361186d565b61122685611a6d565b61122e611b16565b61015f80546001600160a01b0319166001600160a01b0386161790556040517fb3d8a26384852953cab1d93ea954a4ac74e1dc9f5c29576d4a4f45cdb230130e90600090a180156112b9576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6000828152606560205260409020600101546112db8161153c565b610afe8383611546565b6040518060400160405280600581526020016427aba722a960d91b81525061130c906129fe565b6113158161153c565b60008265ffffffffffff16118015611338575062278d0065ffffffffffff831611155b6113845760405162461bcd60e51b815260206004820152601960248201527f73686f727420667265657a65206f7574206f662072616e6765000000000000006044820152606401610926565b60985460405165ffffffffffff80851692600160301b900416907f84af4c1855ea2ef70449c6ae7119d367873ea35277b9681e0e47898900266f9490600090a3506098805465ffffffffffff909216600160301b026bffffffffffff00000000000019909216919091179055565b6040518060400160405280600581526020016427aba722a960d91b815250610a2f906129fe565b604051806040016040528060068152602001652820aaa9a2a960d11b815250610a2f906129fe565b609854600090600160901b900460ff1680611465575060985465ffffffffffff1642105b905090565b6040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b815250611498906129fe565b6114a18161153c565b3360009081526097602052604081208054600192906114c1908490612af9565b909155505033600090815260976020526040812054900361150d5761150d6040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b81525061084c906129fe565b6098546108779061087290600160601b900465ffffffffffff1642612a3b565b6001600160a01b03163b151590565b6108778133611b3f565b611550828261109a565b15610b7d5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60985465ffffffffffff908116908216116115f35760405162461bcd60e51b8152602060048201526006602482015265333937bd32b760d11b6044820152606401610926565b60985460405165ffffffffffff8084169216907f4fd793fe252ef26ede0a814ca52971990ff5ade10f86376fb1914bfb17c57e0890600090a36098805465ffffffffffff191665ffffffffffff92909216919091179055565b611656828261109a565b610b7d5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561168e3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6040518060400160405280600581526020016427aba722a960d91b8152506116f9906129fe565b610b7d8161153c565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561173557610afe83611ba3565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561178f575060408051601f3d908101601f1916820190925261178c91810190612b0c565b60015b6117f25760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610926565b600080516020612c5983398151915281146118615760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610926565b50610afe838383611c3f565b600054610100900460ff166118945760405162461bcd60e51b815260040161092690612b25565b61189c611b16565b6118f26040518060400160405280600581526020016427aba722a960d91b8152506118c6906129fe565b6040518060400160405280600581526020016427aba722a960d91b8152506118ed906129fe565b611c64565b6119246040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b8152506118c6906129fe565b6119556040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b8152506118c6906129fe565b611980604051806040016040528060068152602001652820aaa9a2a960d11b8152506118c6906129fe565b60408051808201909152600581526427aba722a960d91b602082015233906119b1906119ab906129fe565b8261164c565b6119e36040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b8152506119ab906129fe565b611a146040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b8152506119ab906129fe565b611a3f604051806040016040528060068152602001652820aaa9a2a960d11b8152506119ab906129fe565b6001600160a01b038116600090815260976020526040902060069055611a64836112e5565b610afe82610da5565b600054610100900460ff16611a945760405162461bcd60e51b815260040161092690612b25565b611aa18160800151611caf565b611aae8160600151611d61565b611abc816101000151611e13565b611aca816101200151611ec5565b611ad78160400151611f77565b611ae48160a00151612029565b611af18160c001516120db565b611afe8160e0015161218d565b611b0b8160200151612238565b8051610877906122e2565b600054610100900460ff16611b3d5760405162461bcd60e51b815260040161092690612b25565b565b611b49828261109a565b610b7d57611b61816001600160a01b0316601461238d565b611b6c83602061238d565b604051602001611b7d929190612b70565b60408051601f198184030181529082905262461bcd60e51b8252610926916004016128ae565b6001600160a01b0381163b611c105760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610926565b600080516020612c5983398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b611c4883612529565b600082511180611c555750805b15610afe576109fb8383612569565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6001600160a01b038116611d055760405162461bcd60e51b815260206004820152601e60248201527f696e76616c6964204261636b696e674d616e61676572206164647265737300006044820152606401610926565b60cd546040516001600160a01b038084169216907fd4ec685c4e7367fc82d24a1c90d8c91c07a0e204b5b4655fc1a6d5b6b9d9eeb790600090a360cd80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116611db75760405162461bcd60e51b815260206004820152601d60248201527f696e76616c6964204261736b657448616e646c657220616464726573730000006044820152606401610926565b60cc546040516001600160a01b038084169216907fa41efa7d680b9ae9379ca75b956c50587b28ed07453f7d19388c7199397a1e8e90600090a360cc80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116611e695760405162461bcd60e51b815260206004820152601960248201527f696e76616c6964205253525472616465722061646472657373000000000000006044820152606401610926565b60cf546040516001600160a01b038084169216907f2fa6596476f0ebdb5fef9a37bedb7ef956e0e1c4e094464cbf49c38f44f7e8d190600090a360cf80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116611f1b5760405162461bcd60e51b815260206004820152601c60248201527f696e76616c69642052546f6b656e5472616465722061646472657373000000006044820152606401610926565b60d0546040516001600160a01b038084169216907f0d76a5d5849780e9a81127e61df7ee55bf3f766bc326510d3a52ede3caea168f90600090a360d080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116611fcd5760405162461bcd60e51b815260206004820152601d60248201527f696e76616c6964204173736574526567697374727920616464726573730000006044820152606401610926565b60cb546040516001600160a01b038084169216907f5c69d378772ea2f02015deabd3b7ee1db0851dba819e216585de7a155d22a14890600090a360cb80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811661207f5760405162461bcd60e51b815260206004820152601b60248201527f696e76616c6964204469737472696275746f72206164647265737300000000006044820152606401610926565b60ce546040516001600160a01b038084169216907f8c6eabd1db7fe5a1951a7c78767c0e3633c5352578d15d45f99aa4c4db01c55a90600090a360ce80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166121315760405162461bcd60e51b815260206004820152601760248201527f696e76616c6964204675726e61636520616464726573730000000000000000006044820152606401610926565b60d1546040516001600160a01b038084169216907fe0c9d7fae2ccca1a3980ce26aada40d9f7fc84406cdb3adbdcfb8f9dd21c9b5390600090a360d180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166121dc5760405162461bcd60e51b8152602060048201526016602482015275696e76616c69642042726f6b6572206164647265737360501b6044820152606401610926565b60d2546040516001600160a01b038084169216907fc29cab4074359a76aba74458623910a8b95269ded89ad9f98cd2db1de3ead35690600090a360d280546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166122865760405162461bcd60e51b8152602060048201526015602482015274696e76616c6964205374525352206164647265737360581b6044820152606401610926565b60ca546040516001600160a01b038084169216907f1b29dc90e15d6ade122a9e27d886b4a077e66131c7e0cc805fc303e49690c9fc90600090a360ca80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166123315760405162461bcd60e51b8152602060048201526016602482015275696e76616c69642052546f6b656e206164647265737360501b6044820152606401610926565b60c9546040516001600160a01b038084169216907f2d2909c1d06afe38080a70d63a8793874674efb0fdf3b3bf3fd046056688b3ea90600090a360c980546001600160a01b0319166001600160a01b0392909216919091179055565b6060600061239c836002612be5565b6123a7906002612bfc565b67ffffffffffffffff8111156123bf576123bf61273b565b6040519080825280601f01601f1916602001820160405280156123e9576020820181803683370190505b509050600360fc1b8160008151811061240457612404612c0f565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061243357612433612c0f565b60200101906001600160f81b031916908160001a9053506000612457846002612be5565b612462906001612bfc565b90505b60018111156124da576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061249657612496612c0f565b1a60f81b8282815181106124ac576124ac612c0f565b60200101906001600160f81b031916908160001a90535060049490941c936124d381612c25565b9050612465565b5083156110c15760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610926565b61253281611ba3565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6125d15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610926565b600080846001600160a01b0316846040516125ec9190612c3c565b600060405180830381855af49150503d8060008114612627576040519150601f19603f3d011682016040523d82523d6000602084013e61262c565b606091505b50915091506126548282604051806060016040528060278152602001612c796027913961265d565b95945050505050565b6060831561266c5750816110c1565b82511561267c5782518084602001fd5b8160405162461bcd60e51b815260040161092691906128ae565b6000602082840312156126a857600080fd5b81356001600160e01b0319811681146110c157600080fd5b6000602082840312156126d257600080fd5b5035919050565b6001600160a01b038116811461087757600080fd5b6000806040838503121561270157600080fd5b823591506020830135612713816126d9565b809150509250929050565b60006020828403121561273057600080fd5b81356110c1816126d9565b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff811182821017156127755761277561273b565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156127a4576127a461273b565b604052919050565b600080604083850312156127bf57600080fd5b82356127ca816126d9565b915060208381013567ffffffffffffffff808211156127e857600080fd5b818601915086601f8301126127fc57600080fd5b81358181111561280e5761280e61273b565b612820601f8201601f1916850161277b565b9150808252878482850101111561283657600080fd5b80848401858401376000848284010152508093505050509250929050565b803565ffffffffffff8116811461286a57600080fd5b919050565b60006020828403121561288157600080fd5b6110c182612854565b60005b838110156128a557818101518382015260200161288d565b50506000910152565b60208152600082518060208401526128cd81604085016020870161288a565b601f01601f19169190910160400192915050565b803561286a816126d9565b6000806000808486036101a081121561290457600080fd5b6101408082121561291457600080fd5b61291c612751565b9150612927876128e1565b8252612935602088016128e1565b6020830152612946604088016128e1565b6040830152612957606088016128e1565b6060830152612968608088016128e1565b608083015261297960a088016128e1565b60a083015261298a60c088016128e1565b60c083015261299b60e088016128e1565b60e08301526101006129ae8189016128e1565b908301526101206129c08882016128e1565b81840152508195506129d38188016128e1565b945050506129e46101608601612854565b91506129f36101808601612854565b905092959194509250565b80516020808301519190811015612a1f576000198160200360031b1b821691505b50919050565b634e487b7160e01b600052601160045260246000fd5b65ffffffffffff818116838216019080821115612a5a57612a5a612a25565b5092915050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b818103818111156107dc576107dc612a25565b600060208284031215612b1e57600080fd5b5051919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612ba881601785016020880161288a565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612bd981602884016020880161288a565b01602801949350505050565b80820281158282048414176107dc576107dc612a25565b808201808211156107dc576107dc612a25565b634e487b7160e01b600052603260045260246000fd5b600081612c3457612c34612a25565b506000190190565b60008251612c4e81846020870161288a565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220cedf452fe1fb140dafea532899102992f49b446781d12e41354a9a984569b2e764736f6c63430008110033","decoded_constructor_args":null,"deployed_bytecode":"0x60806040526004361061025c5760003560e01c80635c975abb11610144578063bfe10928116100b6578063e083b5e61161007a578063e083b5e614610704578063e58378bb14610731578063e63ab1e914610746578063f17063751461075b578063f8aa0c4e14610770578063fe8aa12a1461079657600080fd5b8063bfe1092814610663578063c99dc3dd14610683578063d547741f146106a4578063dc8af5f6146106c4578063de1611cf146106e457600080fd5b806391d148541161010857806391d14854146105b957806394c7f299146105d9578063979d7e86146105ee578063992e1d6a1461060e578063a217fddf1461062e578063abff01101461064357600080fd5b80635c975abb1461052f578063656e96e1146105505780636a28f00014610570578063705a6618146105855780638456cb59146105a457600080fd5b80633659cfe6116101dd5780634f1ef286116101a15780634f1ef2861461047e5780635187ae681461049157806352d1902d146104b157806353136763146104c657806354fd4d50146104e6578063590f6b1a1461051a57600080fd5b80633659cfe6146103e95780633f4ba83a1461040957806340c65f721461041e57806341bf0c4e1461043e5780634780a5e51461045e57600080fd5b80632b56d18a116102245780632b56d18a1461031f5780632d8709601461035c5780632f2439b1146103715780632f2ff15d146103a957806336568abe146103c957600080fd5b806301ffc9a714610261578063054f7d9c146102965780630f702ed3146102b557806318178358146102cc578063248a9ca3146102e1575b600080fd5b34801561026d57600080fd5b5061028161027c366004612696565b6107ab565b60405190151581526020015b60405180910390f35b3480156102a257600080fd5b5060985465ffffffffffff164210610281565b3480156102c157600080fd5b506102ca6107e2565b005b3480156102d857600080fd5b506102ca61087a565b3480156102ed57600080fd5b506103116102fc3660046126c0565b60009081526065602052604090206001015490565b60405190815260200161028d565b34801561032b57600080fd5b5060985461034590600160301b900465ffffffffffff1681565b60405165ffffffffffff909116815260200161028d565b34801561036857600080fd5b50610311610a01565b34801561037d57600080fd5b5060cc54610391906001600160a01b031681565b6040516001600160a01b03909116815260200161028d565b3480156103b557600080fd5b506102ca6103c43660046126ee565b610a32565b3480156103d557600080fd5b506102ca6103e43660046126ee565b610b03565b3480156103f557600080fd5b506102ca61040436600461271e565b610b81565b34801561041557600080fd5b506102ca610c5d565b34801561042a57600080fd5b5060c954610391906001600160a01b031681565b34801561044a57600080fd5b5060d054610391906001600160a01b031681565b34801561046a57600080fd5b5060ca54610391906001600160a01b031681565b6102ca61048c3660046127ac565b610cd9565b34801561049d57600080fd5b506102ca6104ac36600461286f565b610da5565b3480156104bd57600080fd5b50610311610eb0565b3480156104d257600080fd5b5060cf54610391906001600160a01b031681565b3480156104f257600080fd5b5060408051808201825260058152640322e302e360dc1b6020820152905161028d91906128ae565b34801561052657600080fd5b50610311610f63565b34801561053b57600080fd5b5060985461028190600160901b900460ff1681565b34801561055c57600080fd5b5060d154610391906001600160a01b031681565b34801561057c57600080fd5b506102ca610f92565b34801561059157600080fd5b506098546103459065ffffffffffff1681565b3480156105b057600080fd5b506102ca611017565b3480156105c557600080fd5b506102816105d43660046126ee565b61109a565b3480156105e557600080fd5b506102ca6110c8565b3480156105fa57600080fd5b5060cb54610391906001600160a01b031681565b34801561061a57600080fd5b506102ca6106293660046128ec565b611107565b34801561063a57600080fd5b50610311600081565b34801561064f57600080fd5b5060d254610391906001600160a01b031681565b34801561066f57600080fd5b5060ce54610391906001600160a01b031681565b34801561068f57600080fd5b5061015f54610391906001600160a01b031681565b3480156106b057600080fd5b506102ca6106bf3660046126ee565b6112c0565b3480156106d057600080fd5b5060cd54610391906001600160a01b031681565b3480156106f057600080fd5b506102ca6106ff36600461286f565b6112e5565b34801561071057600080fd5b5061031161071f36600461271e565b60976020526000908152604090205481565b34801561073d57600080fd5b506103116113f2565b34801561075257600080fd5b50610311611419565b34801561076757600080fd5b50610281611441565b34801561077c57600080fd5b5060985461034590600160601b900465ffffffffffff1681565b3480156107a257600080fd5b506102ca61146a565b60006001600160e01b03198216637965db0b60e01b14806107dc57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b815250610811906129fe565b61081a8161153c565b6108526040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b81525061084c906129fe565b33611546565b6098546108779061087290600160301b900465ffffffffffff1642612a3b565b6115ad565b50565b60cb60009054906101000a90046001600160a01b03166001600160a01b031663f8ac93e86040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156108ca57600080fd5b505af11580156108de573d6000803e3d6000fd5b505050506108ea611441565b1561092f5760405162461bcd60e51b815260206004820152601060248201526f3830bab9b2b21037b910333937bd32b760811b60448201526064015b60405180910390fd5b60d160009054906101000a90046001600160a01b03166001600160a01b0316635220f5106040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561097f57600080fd5b505af1158015610993573d6000803e3d6000fd5b5050505060ca60009054906101000a90046001600160a01b03166001600160a01b031663296130866040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156109e757600080fd5b505af11580156109fb573d6000803e3d6000fd5b50505050565b6040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b815250610a2f906129fe565b81565b600082815260656020526040902060010154610a4d8161153c565b6001600160a01b038216610aa35760405162461bcd60e51b815260206004820152601e60248201527f63616e6e6f74206772616e7420726f6c6520746f2061646472657373203000006044820152606401610926565b6040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b815250610ad1906129fe565b8303610af4576001600160a01b0382166000908152609760205260409020600690555b610afe838361164c565b505050565b6001600160a01b0381163314610b735760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610926565b610b7d8282611546565b5050565b6001600160a01b037f000000000000000000000000143c35bfe04720394ebd18abeca83ea9d8bede2f163003610bc95760405162461bcd60e51b815260040161092690612a61565b7f000000000000000000000000143c35bfe04720394ebd18abeca83ea9d8bede2f6001600160a01b0316610c12600080516020612c59833981519152546001600160a01b031690565b6001600160a01b031614610c385760405162461bcd60e51b815260040161092690612aad565b610c41816116d2565b6040805160008082526020820190925261087791839190611702565b604051806040016040528060068152602001652820aaa9a2a960d11b815250610c85906129fe565b610c8e8161153c565b609854604051600091600160901b900460ff161515907f8a03df86592b6c04a66160b441f1d7282689edca334882d14f468dc60352b0ff908390a3506098805460ff60901b19169055565b6001600160a01b037f000000000000000000000000143c35bfe04720394ebd18abeca83ea9d8bede2f163003610d215760405162461bcd60e51b815260040161092690612a61565b7f000000000000000000000000143c35bfe04720394ebd18abeca83ea9d8bede2f6001600160a01b0316610d6a600080516020612c59833981519152546001600160a01b031690565b6001600160a01b031614610d905760405162461bcd60e51b815260040161092690612aad565b610d99826116d2565b610b7d82826001611702565b6040518060400160405280600581526020016427aba722a960d91b815250610dcc906129fe565b610dd58161153c565b60008265ffffffffffff16118015610df957506301e1338065ffffffffffff831611155b610e455760405162461bcd60e51b815260206004820152601860248201527f6c6f6e6720667265657a65206f7574206f662072616e676500000000000000006044820152606401610926565b60985460405165ffffffffffff80851692600160601b900416907f2b855a9093ce8fb8bd37179aa306b424a5008d3a000751f4c2e721c51b89f9a290600090a3506098805465ffffffffffff909216600160601b0265ffffffffffff60601b19909216919091179055565b6000306001600160a01b037f000000000000000000000000143c35bfe04720394ebd18abeca83ea9d8bede2f1614610f505760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610926565b50600080516020612c5983398151915290565b6040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b815250610a2f906129fe565b6040518060400160405280600581526020016427aba722a960d91b815250610fb9906129fe565b610fc28161153c565b60985460405165ffffffffffff4281169216907f4fd793fe252ef26ede0a814ca52971990ff5ade10f86376fb1914bfb17c57e0890600090a3506098805465ffffffffffff19164265ffffffffffff16179055565b604051806040016040528060068152602001652820aaa9a2a960d11b81525061103f906129fe565b6110488161153c565b609854604051600191600160901b900460ff161515907f8a03df86592b6c04a66160b441f1d7282689edca334882d14f468dc60352b0ff90600090a3506098805460ff60901b1916600160901b179055565b60008281526065602090815260408083206001600160a01b038516845290915281205460ff165b9392505050565b6040518060400160405280600581526020016427aba722a960d91b8152506110ef906129fe565b6110f88161153c565b61087765ffffffffffff6115ad565b600054610100900460ff16158080156111275750600054600160ff909116105b806111415750303b158015611141575060005460ff166001145b6111a45760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610926565b6000805460ff1916600117905580156111c7576000805461ff0019166101001790555b6001600160a01b0384166112135760405162461bcd60e51b8152602060048201526013602482015272696e76616c696420525352206164647265737360681b6044820152606401610926565b61121d838361186d565b61122685611a6d565b61122e611b16565b61015f80546001600160a01b0319166001600160a01b0386161790556040517fb3d8a26384852953cab1d93ea954a4ac74e1dc9f5c29576d4a4f45cdb230130e90600090a180156112b9576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6000828152606560205260409020600101546112db8161153c565b610afe8383611546565b6040518060400160405280600581526020016427aba722a960d91b81525061130c906129fe565b6113158161153c565b60008265ffffffffffff16118015611338575062278d0065ffffffffffff831611155b6113845760405162461bcd60e51b815260206004820152601960248201527f73686f727420667265657a65206f7574206f662072616e6765000000000000006044820152606401610926565b60985460405165ffffffffffff80851692600160301b900416907f84af4c1855ea2ef70449c6ae7119d367873ea35277b9681e0e47898900266f9490600090a3506098805465ffffffffffff909216600160301b026bffffffffffff00000000000019909216919091179055565b6040518060400160405280600581526020016427aba722a960d91b815250610a2f906129fe565b604051806040016040528060068152602001652820aaa9a2a960d11b815250610a2f906129fe565b609854600090600160901b900460ff1680611465575060985465ffffffffffff1642105b905090565b6040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b815250611498906129fe565b6114a18161153c565b3360009081526097602052604081208054600192906114c1908490612af9565b909155505033600090815260976020526040812054900361150d5761150d6040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b81525061084c906129fe565b6098546108779061087290600160601b900465ffffffffffff1642612a3b565b6001600160a01b03163b151590565b6108778133611b3f565b611550828261109a565b15610b7d5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60985465ffffffffffff908116908216116115f35760405162461bcd60e51b8152602060048201526006602482015265333937bd32b760d11b6044820152606401610926565b60985460405165ffffffffffff8084169216907f4fd793fe252ef26ede0a814ca52971990ff5ade10f86376fb1914bfb17c57e0890600090a36098805465ffffffffffff191665ffffffffffff92909216919091179055565b611656828261109a565b610b7d5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561168e3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6040518060400160405280600581526020016427aba722a960d91b8152506116f9906129fe565b610b7d8161153c565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561173557610afe83611ba3565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561178f575060408051601f3d908101601f1916820190925261178c91810190612b0c565b60015b6117f25760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610926565b600080516020612c5983398151915281146118615760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610926565b50610afe838383611c3f565b600054610100900460ff166118945760405162461bcd60e51b815260040161092690612b25565b61189c611b16565b6118f26040518060400160405280600581526020016427aba722a960d91b8152506118c6906129fe565b6040518060400160405280600581526020016427aba722a960d91b8152506118ed906129fe565b611c64565b6119246040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b8152506118c6906129fe565b6119556040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b8152506118c6906129fe565b611980604051806040016040528060068152602001652820aaa9a2a960d11b8152506118c6906129fe565b60408051808201909152600581526427aba722a960d91b602082015233906119b1906119ab906129fe565b8261164c565b6119e36040518060400160405280600d81526020016c29a427a92a2fa32922a2ad22a960991b8152506119ab906129fe565b611a146040518060400160405280600c81526020016b2627a723afa32922a2ad22a960a11b8152506119ab906129fe565b611a3f604051806040016040528060068152602001652820aaa9a2a960d11b8152506119ab906129fe565b6001600160a01b038116600090815260976020526040902060069055611a64836112e5565b610afe82610da5565b600054610100900460ff16611a945760405162461bcd60e51b815260040161092690612b25565b611aa18160800151611caf565b611aae8160600151611d61565b611abc816101000151611e13565b611aca816101200151611ec5565b611ad78160400151611f77565b611ae48160a00151612029565b611af18160c001516120db565b611afe8160e0015161218d565b611b0b8160200151612238565b8051610877906122e2565b600054610100900460ff16611b3d5760405162461bcd60e51b815260040161092690612b25565b565b611b49828261109a565b610b7d57611b61816001600160a01b0316601461238d565b611b6c83602061238d565b604051602001611b7d929190612b70565b60408051601f198184030181529082905262461bcd60e51b8252610926916004016128ae565b6001600160a01b0381163b611c105760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610926565b600080516020612c5983398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b611c4883612529565b600082511180611c555750805b15610afe576109fb8383612569565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6001600160a01b038116611d055760405162461bcd60e51b815260206004820152601e60248201527f696e76616c6964204261636b696e674d616e61676572206164647265737300006044820152606401610926565b60cd546040516001600160a01b038084169216907fd4ec685c4e7367fc82d24a1c90d8c91c07a0e204b5b4655fc1a6d5b6b9d9eeb790600090a360cd80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116611db75760405162461bcd60e51b815260206004820152601d60248201527f696e76616c6964204261736b657448616e646c657220616464726573730000006044820152606401610926565b60cc546040516001600160a01b038084169216907fa41efa7d680b9ae9379ca75b956c50587b28ed07453f7d19388c7199397a1e8e90600090a360cc80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116611e695760405162461bcd60e51b815260206004820152601960248201527f696e76616c6964205253525472616465722061646472657373000000000000006044820152606401610926565b60cf546040516001600160a01b038084169216907f2fa6596476f0ebdb5fef9a37bedb7ef956e0e1c4e094464cbf49c38f44f7e8d190600090a360cf80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116611f1b5760405162461bcd60e51b815260206004820152601c60248201527f696e76616c69642052546f6b656e5472616465722061646472657373000000006044820152606401610926565b60d0546040516001600160a01b038084169216907f0d76a5d5849780e9a81127e61df7ee55bf3f766bc326510d3a52ede3caea168f90600090a360d080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116611fcd5760405162461bcd60e51b815260206004820152601d60248201527f696e76616c6964204173736574526567697374727920616464726573730000006044820152606401610926565b60cb546040516001600160a01b038084169216907f5c69d378772ea2f02015deabd3b7ee1db0851dba819e216585de7a155d22a14890600090a360cb80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811661207f5760405162461bcd60e51b815260206004820152601b60248201527f696e76616c6964204469737472696275746f72206164647265737300000000006044820152606401610926565b60ce546040516001600160a01b038084169216907f8c6eabd1db7fe5a1951a7c78767c0e3633c5352578d15d45f99aa4c4db01c55a90600090a360ce80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166121315760405162461bcd60e51b815260206004820152601760248201527f696e76616c6964204675726e61636520616464726573730000000000000000006044820152606401610926565b60d1546040516001600160a01b038084169216907fe0c9d7fae2ccca1a3980ce26aada40d9f7fc84406cdb3adbdcfb8f9dd21c9b5390600090a360d180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166121dc5760405162461bcd60e51b8152602060048201526016602482015275696e76616c69642042726f6b6572206164647265737360501b6044820152606401610926565b60d2546040516001600160a01b038084169216907fc29cab4074359a76aba74458623910a8b95269ded89ad9f98cd2db1de3ead35690600090a360d280546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166122865760405162461bcd60e51b8152602060048201526015602482015274696e76616c6964205374525352206164647265737360581b6044820152606401610926565b60ca546040516001600160a01b038084169216907f1b29dc90e15d6ade122a9e27d886b4a077e66131c7e0cc805fc303e49690c9fc90600090a360ca80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166123315760405162461bcd60e51b8152602060048201526016602482015275696e76616c69642052546f6b656e206164647265737360501b6044820152606401610926565b60c9546040516001600160a01b038084169216907f2d2909c1d06afe38080a70d63a8793874674efb0fdf3b3bf3fd046056688b3ea90600090a360c980546001600160a01b0319166001600160a01b0392909216919091179055565b6060600061239c836002612be5565b6123a7906002612bfc565b67ffffffffffffffff8111156123bf576123bf61273b565b6040519080825280601f01601f1916602001820160405280156123e9576020820181803683370190505b509050600360fc1b8160008151811061240457612404612c0f565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061243357612433612c0f565b60200101906001600160f81b031916908160001a9053506000612457846002612be5565b612462906001612bfc565b90505b60018111156124da576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061249657612496612c0f565b1a60f81b8282815181106124ac576124ac612c0f565b60200101906001600160f81b031916908160001a90535060049490941c936124d381612c25565b9050612465565b5083156110c15760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610926565b61253281611ba3565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6125d15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610926565b600080846001600160a01b0316846040516125ec9190612c3c565b600060405180830381855af49150503d8060008114612627576040519150601f19603f3d011682016040523d82523d6000602084013e61262c565b606091505b50915091506126548282604051806060016040528060278152602001612c796027913961265d565b95945050505050565b6060831561266c5750816110c1565b82511561267c5782518084602001fd5b8160405162461bcd60e51b815260040161092691906128ae565b6000602082840312156126a857600080fd5b81356001600160e01b0319811681146110c157600080fd5b6000602082840312156126d257600080fd5b5035919050565b6001600160a01b038116811461087757600080fd5b6000806040838503121561270157600080fd5b823591506020830135612713816126d9565b809150509250929050565b60006020828403121561273057600080fd5b81356110c1816126d9565b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff811182821017156127755761277561273b565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156127a4576127a461273b565b604052919050565b600080604083850312156127bf57600080fd5b82356127ca816126d9565b915060208381013567ffffffffffffffff808211156127e857600080fd5b818601915086601f8301126127fc57600080fd5b81358181111561280e5761280e61273b565b612820601f8201601f1916850161277b565b9150808252878482850101111561283657600080fd5b80848401858401376000848284010152508093505050509250929050565b803565ffffffffffff8116811461286a57600080fd5b919050565b60006020828403121561288157600080fd5b6110c182612854565b60005b838110156128a557818101518382015260200161288d565b50506000910152565b60208152600082518060208401526128cd81604085016020870161288a565b601f01601f19169190910160400192915050565b803561286a816126d9565b6000806000808486036101a081121561290457600080fd5b6101408082121561291457600080fd5b61291c612751565b9150612927876128e1565b8252612935602088016128e1565b6020830152612946604088016128e1565b6040830152612957606088016128e1565b6060830152612968608088016128e1565b608083015261297960a088016128e1565b60a083015261298a60c088016128e1565b60c083015261299b60e088016128e1565b60e08301526101006129ae8189016128e1565b908301526101206129c08882016128e1565b81840152508195506129d38188016128e1565b945050506129e46101608601612854565b91506129f36101808601612854565b905092959194509250565b80516020808301519190811015612a1f576000198160200360031b1b821691505b50919050565b634e487b7160e01b600052601160045260246000fd5b65ffffffffffff818116838216019080821115612a5a57612a5a612a25565b5092915050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b818103818111156107dc576107dc612a25565b600060208284031215612b1e57600080fd5b5051919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612ba881601785016020880161288a565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612bd981602884016020880161288a565b01602801949350505050565b80820281158282048414176107dc576107dc612a25565b808201808211156107dc576107dc612a25565b634e487b7160e01b600052603260045260246000fd5b600081612c3457612c34612a25565b506000190190565b60008251612c4e81846020870161288a565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220cedf452fe1fb140dafea532899102992f49b446781d12e41354a9a984569b2e764736f6c63430008110033","evm_version":"london","external_libraries":[],"file_path":"contracts/p1/Main.sol","is_changed_bytecode":false,"is_fully_verified":true,"is_partially_verified":false,"is_self_destructed":false,"is_verified":true,"is_verified_via_eth_bytecode_db":false,"is_verified_via_sourcify":true,"is_vyper_contract":false,"language":"solidity","minimal_proxy_address_hash":null,"name":"MainP1","optimization_enabled":true,"optimization_runs":200,"source_code":"// SPDX-License-Identifier: BlueOak-1.0.0\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../interfaces/IMain.sol\";\nimport \"../mixins/ComponentRegistry.sol\";\nimport \"../mixins/Auth.sol\";\nimport \"../mixins/Versioned.sol\";\n\n/**\n * @title Main\n * @notice The center of the system around which Components orbit.\n */\n// solhint-disable max-states-count\ncontract MainP1 is Versioned, Initializable, Auth, ComponentRegistry, UUPSUpgradeable, IMain {\n    IERC20 public rsr;\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    // solhint-disable-next-line no-empty-blocks\n    constructor() initializer {}\n\n    /// Initializer\n    function init(\n        Components memory components,\n        IERC20 rsr_,\n        uint48 shortFreeze_,\n        uint48 longFreeze_\n    ) public virtual initializer {\n        require(address(rsr_) != address(0), \"invalid RSR address\");\n        __Auth_init(shortFreeze_, longFreeze_);\n        __ComponentRegistry_init(components);\n        __UUPSUpgradeable_init();\n\n        rsr = rsr_;\n        emit MainInitialized();\n    }\n\n    /// @custom:refresher\n    /// @custom:interaction CEI\n    function poke() external {\n        // == Refresher ==\n        assetRegistry.refresh();\n\n        // == CE block ==\n        require(!pausedOrFrozen(), \"paused or frozen\");\n        furnace.melt();\n        stRSR.payoutRewards();\n    }\n\n    function hasRole(bytes32 role, address account)\n        public\n        view\n        override(IAccessControlUpgradeable, AccessControlUpgradeable)\n        returns (bool)\n    {\n        return super.hasRole(role, account);\n    }\n\n    // === Upgradeability ===\n    // solhint-disable-next-line no-empty-blocks\n    function _authorizeUpgrade(address newImplementation) internal override onlyRole(OWNER) {}\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n","sourcify_repo_url":"https://repo.sourcify.dev/contracts/full_match/369/0x143C35bFe04720394eBd18AbECa83eA9D8BEdE2F/","verified_at":"2026-05-17T10:32:06.505943Z","verified_twin_address_hash":null}