creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/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. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\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"
      },
      "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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 * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\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.\n     *\n     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\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     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\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     * WARNING: setting the version to 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\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     * Emits an {Initialized} event the first time it is successfully executed.\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    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _initializing;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, \"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(address target, bytes memory data, uint256 value) 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        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, 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        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\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(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or 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            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\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"
      },
      "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
        "content": "// 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"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "contracts/interfaces/IMatchPool.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.19;\n\ninterface IMatchPool {\n\tfunction getMintPool() external view returns (address);\n\t// Total amount of ETH-LBR staked\n\tfunction totalStaked() external view returns (uint256);\n\tfunction staked(address _user) external view returns (uint256);\n\t// Total amount of stETH deposited to contract\n\tfunction totalSupplied(address _mintPool) external view returns (uint256);\n\tfunction supplied(address _mintPool, address _user) external view returns (uint256);\n\tfunction totalMinted(address _mintPool) external view returns (uint256);\n\tfunction claimRebase() external returns (uint256);\n\tfunction borrowed(address _mintPool, address _account) external view returns (uint256, uint256, uint256, uint256);\n\tfunction claimRewards() external;\n\t// !! @modify Code added by Eric 20231030\n    function claimProtocolRevenue() external;\n}"
      },
      "contracts/interfaces/IRewardDistributorFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.19;\n\ninterface IRewardDistributorFactory {\n    function pendingReward(address rewardToken, address receiver) external view returns (uint256);\n\n    function distribute(address rewardToken) external returns (uint256);\n\n    function distributors(address rewardToken, address receiver) external view returns (address);\n}"
      },
      "contracts/interfaces/LybraInterfaces.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.19;\n\ninterface IMining {\n    function refreshReward(address user) external;\n    function getReward() external;\n}\n\ninterface IStakePool {\n    function stake(uint256 _amount) external;\n    function withdraw(uint256 _amount) external;\n    function getReward() external;\n    // Get esLBR address from dlp stake pool\n    function rewardsToken() external view returns (address);\n}\n\ninterface IMintPool {\n    function getAsset() external view returns(address);\n    function depositAssetToMint(uint256 assetAmount, uint256 mintAmount) external;\n    function depositedAsset(address _user) external view returns (uint256);\n    // Price of stETH, scaled in 1e18\n    function getAssetPrice() external returns (uint256);\n    function withdraw(address onBehalfOf, uint256 amount) external;\n    function mint(address onBehalfOf, uint256 amount) external;\n    function burn(address onBehalfOf, uint256 amount) external;\n    function checkWithdrawal(address user, uint256 amount) external view returns (uint256 withdrawal);\n    function getPoolTotalCirculation() external view returns (uint256);\n    function getBorrowedOf(address user) external view returns (uint256);\n}\n\ninterface IConfigurator {\n    function getVaultWeight(address pool) external view returns (uint256);\n    function getEUSDAddress() external view returns (address);\n    function refreshMintReward(address _account) external;\n    function eUSDMiningIncentives() external view returns (address);\n    function getProtocolRewardsPool() external view returns (address);\n    function peUSD() external view returns (address);\n    function stableToken() external view returns (address);\n}\n\n// eUSD mining incentive, dlp stake reward pool\ninterface IRewardPool {\n    function stakedOf(address user) external view returns (uint256);\n    function totalStaked() external view returns (uint256);\n    function balanceOf(address user) external view returns (uint256);\n    function getBoost(address _account) external view returns (uint256);\n    function rewardPerToken() external view returns (uint256);\n    function earned(address _account) external view returns (uint256);\n    function refreshReward(address _account) external;\n    function getReward() external;\n    // Vest esLBR at protocol reward contract\n    function unstake(uint256 amount) external;\n}\n\ninterface IEUSD {\n    function totalSupply() external view returns (uint256);\n\n    function getTotalShares() external view returns (uint256);\n\n    function balanceOf(address account) external view returns (uint256);\n\n    function sharesOf(address _account) external view returns (uint256);\n\n    function allowance(\n        address owner,\n        address spender\n    ) external view returns (uint256);\n\n    function approve(address _spender, uint256 _amount) external returns (bool);\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n\n    function transferShares(\n        address _recipient,\n        uint256 _sharesAmount\n    ) external returns (uint256);\n\n    function getSharesByMintedEUSD(\n        uint256 _EUSDAmount\n    ) external view returns (uint256);\n\n    function getMintedEUSDByShares(\n        uint256 _sharesAmount\n    ) external view returns (uint256);\n\n    function mint(\n        address _recipient,\n        uint256 _mintAmount\n    ) external returns (uint256 newTotalShares);\n\n    function burnShares(\n        address _account,\n        uint256 burnAmount\n    ) external returns (uint256 newTotalShares);\n\n    function burn(\n        address _account,\n        uint256 burnAmount\n    ) external returns (uint256 newTotalShares);\n\n    function transfer(address to, uint256 amount) external returns (bool);\n}\n\ninterface IesLBRBoost {\n    function setLockStatus(uint256 id, uint256 lbrAmount, bool useLBR) external;\n    function getUserBoost(address user, uint256 userUpdatedAt, uint256 finishAt) external view returns (uint256);\n}\n\n"
      },
      "contracts/RewardManager.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.19;\n\nimport { Initializable } from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"./interfaces/LybraInterfaces.sol\";\nimport \"./interfaces/IMatchPool.sol\";\nimport \"./interfaces/IRewardDistributorFactory.sol\";\n\ninterface IERC20Mintable {\n\tfunction mint(address _to, uint256 _amount) external;\n}\n\nerror Unauthorized();\nerror UnpaidInterest(uint256 unpaidAmount);\n\ncontract RewardManager is Initializable, OwnableUpgradeable {\n\tIMatchPool public matchPool;\n\n\t// reward pool => amount\n\t// 1. dlp reward pool (dlp + 20% mining incentive) \n\t// 2. lsd reward pool (80% mining incentive)\n\t// 3. eUSD (rebase)\n\tmapping(address => uint256) public rewardPerTokenStored;\n\t// Last update timestamp in reward pool may not be now\n\t// Maintain own version of token paid for calculating most updated reward amount\n\tmapping(address => uint256) public rewardPerTokenPaid;\n\t// reward pool => account => amount\n\tmapping(address => mapping(address => uint256)) public userRewardsPerTokenPaid;\n\tmapping(address => mapping(address => uint256)) public userRewards;\n\n\t// Total amount of eUSD claimed from Match Pool\n\t// Get actual claim amount after/if eUSD has rebased within this contract\n\tuint256 totalEUSD;\n\n\taddress public dlpRewardPool; // stake reward pool\n\taddress public miningIncentive; // eUSD mining incentive\n\taddress public eUSD; // eUSD rebase\n\t// Receive eUSD rebase and esLBR from mining incentive;\n\taddress public treasury;\n\n\t// Mining reward share, out of 100\n\tuint128 treasuryShare;\n\tuint128 stakerShare;\n\n\tIERC20Mintable public mesLBR;\n\n\t// !! @modify Eric 20231030\n    uint256 public pendingBoostReward;\n\n    // reward pool => last updated earned() amount from Lybra\n\tmapping(address => uint256) public earnedPaid;\n\n\t// !! @modify Eric 20231030\n    address public mesLBRStaking;\n    address public vlMatchStaking;\n\n    IConfigurator public lybraConfigurator;\n\n    IRewardDistributorFactory public rewardDistributorFactory;\n\n\tevent dlpRewardPoolChanged(address newPool);\n\tevent MiningRewardPoolsChanged(address newMining, address newEUSD);\n\tevent RewardShareChanged(uint128 newTreasuryShare, uint128 newStakerShare);\n\tevent TreasuryChanged(address newTreasury);\n\tevent mesLBRChanged(address newMesLBR);\n\tevent mesLBRStakingPoolChanged(address newPool);\n\tevent vlMatchStakingChanged(address newPool);\n\tevent LybraConfiguratorChanged(address newConfigurator);\n\tevent RewardDistributorFactoryChanged(address newFactory);\n\tevent mesLBRRewardClaimed(address account, uint256 rewardAmount);\n\tevent eUSDRewardClaimed(address account, uint256 rewardAmount);\n\tevent RewardDistributedToDistributors(\n        uint256 boostReward,\n        uint256 treasuryReward,\n        uint256 peUSDAmount,\n        uint256 altStablecoinAmount\n    );\n\n\t// // Initialize function for testing\n\t// function initializeTest(address _matchPool) public initializer {\n\t// \t__Ownable_init();\n\n    //     matchPool = IMatchPool(_matchPool);\n    //     setMiningRewardShares(10, 10);\n    // }\n\n\t/**\n     * @notice Rewards earned by Match Pool since last update, get most updated value by directly calculating\n     */\n    function earnedSinceLastUpdate(address _rewardPool) public view returns (uint256, uint256, uint256, uint256) {\n        IRewardPool rewardPool = IRewardPool(_rewardPool);\n        address _matchPool = address(matchPool);\n\n        uint256 rpt = rewardPool.rewardPerToken();\n        uint256 earnedFromLybra = rewardPool.earned(_matchPool);\n        uint256 totalReward = earnedFromLybra - earnedPaid[_rewardPool];\n        if (totalReward == 0) return (0, rpt, 0, earnedFromLybra);\n\n        uint256 matchPoolShares;\n\n        // DLP reward pool is calculated with the staked amount of \"DLP\"\n        if (_rewardPool == dlpRewardPool) matchPoolShares = rewardPool.balanceOf(_matchPool);\n        // eUSD mining incentive pool is calculated with the total borrowed(minted) amount of eUSD or peUSD\n        else if (_rewardPool == miningIncentive) matchPoolShares = rewardPool.stakedOf(_matchPool);\n        else return (0, 0, 0, 0);\n\n        // !! @modify Code added by Eric 20231030\n        // Seperate earned esLBR to two parts: normal and boost\n        // Boost part goes to mesLBR stakers\n        uint256 normalReward = (matchPoolShares * (rpt - rewardPerTokenPaid[_rewardPool])) / 1e18;\n        uint256 boostReward = totalReward - normalReward;\n\n        // !! @modify Code added by Eric 20231030\n        // Only return normal reward part\n        return (normalReward, rpt, boostReward, earnedFromLybra);\n    }\n\n\tfunction rewardPerToken(address _rewardPool) public view returns (uint256) {\n\t\t(uint256 dlpEarned, , , ) = earnedSinceLastUpdate(dlpRewardPool);\n\t\t(uint256 lsdEarned, , , ) = earnedSinceLastUpdate(miningIncentive);\n\t\tuint256 rewardAmount;\n\t\tif (_rewardPool == dlpRewardPool) rewardAmount = dlpEarned + lsdEarned * stakerShare / 100;\n\t\telse if (_rewardPool == miningIncentive) \n\t\t\trewardAmount = lsdEarned * (100 - stakerShare - treasuryShare) / 100;\n\n\t\treturn _rewardPerToken(_rewardPool, rewardAmount);\n\t}\n\n\tfunction earned(address _account, address _rewardPool) public view returns (uint256) {\n\t\treturn _earned(_rewardPool, _account, rewardPerToken(_rewardPool));\n\t}\n\n\tfunction setDlpRewardPool(address _dlp) external onlyOwner {\n\t\tdlpRewardPool = _dlp;\n\n\t\temit dlpRewardPoolChanged(_dlp);\n\t}\n\n\tfunction setMiningRewardPools(address _mining, address _eUSD) external onlyOwner {\n\t\tminingIncentive = _mining;\n\t\teUSD = _eUSD;\n\n\t\temit MiningRewardPoolsChanged(_mining, _eUSD);\n\t}\n\n\tfunction setMiningRewardShares(uint128 _treasuryShare, uint128 _stakerShare) public onlyOwner {\n\t\ttreasuryShare = _treasuryShare;\n\t\tstakerShare = _stakerShare;\n\n\t\temit RewardShareChanged(_treasuryShare, _stakerShare);\n\t}\n\n\tfunction setTreasury(address _treasury) external onlyOwner {\n\t\ttreasury = _treasury;\n\n\t\temit TreasuryChanged(_treasury);\n\t}\n\n\tfunction setMesLBR(address _mesLBR) external onlyOwner {\n\t\tmesLBR = IERC20Mintable(_mesLBR);\n\n\t\temit mesLBRChanged(_mesLBR);\n\t}\n\n\tfunction setMesLBRStakingPool(address _mesLBRStaking) external onlyOwner {\n        mesLBRStaking = _mesLBRStaking;\n        emit mesLBRStakingPoolChanged(_mesLBRStaking);\n    }\n\n    function setVlMatchStaking(address _vlMatchStaking) external onlyOwner {\n    \tvlMatchStaking = _vlMatchStaking;\n    \temit vlMatchStakingChanged(_vlMatchStaking);\n    }\n\n    function setLybraConfigurator(address _lybraConfigurator) external onlyOwner {\n        lybraConfigurator = IConfigurator(_lybraConfigurator);\n        emit LybraConfiguratorChanged(_lybraConfigurator);\n    }\n\n    function setRewardDistributorFactory(address _factory) external onlyOwner {\n    \trewardDistributorFactory = IRewardDistributorFactory(_factory);\n    \temit RewardDistributorFactoryChanged(_factory);\n    }\n\n    function setRewardCalc(address _rewardPool, uint256 _val) external onlyOwner {\n    \tearnedPaid[_rewardPool] = _val;\n    }\n\t\n\t// Update rewards for dlp stakers, includes esLBR from dlp and eUSD\n\tfunction dlpUpdateReward(address _account) external {\n\t\t// Boost multiplier obtained for calculating mining reward may not be the actual one \n\t\t// Lybra uses if only just reward manager is updated\n\t\tif(msg.sender != address(matchPool)) revert Unauthorized();\n\t\t_dlpUpdateReward(_account);\n\t}\n\n\tfunction lsdUpdateReward(address _account) external {\n\t\t// Boost multiplier obtained for calculating mining reward may not be the actual one \n\t\t// Lybra uses if only just reward manager is updated\n\t\tif(msg.sender != address(matchPool)) revert Unauthorized();\n\t\t_lsdUpdateReward(_account);\n\t\t_eusdUpdateReward(_account);\n\t}\n\n\tfunction claimLybraRewards() external {\n\t\t// Calculate reward earned since last update till right before claiming.\n\t\t// No need to update eUSD reward as claiming rewards from Lybra does not affect supply balances\n\t\t// dlpUpdateReward() updates both dlp and mining incentive rewards\n\t\t_dlpUpdateReward(address(0));\n\t\tmatchPool.claimRewards();\n\t\tearnedPaid[dlpRewardPool] = 0;\n\t\tearnedPaid[miningIncentive] = 0;\n\t}\n\n\tfunction claimTreasury() external onlyOwner {\n\t\taddress _treasury = treasury;\n\t\tuint256 rewardToTreasury = userRewards[miningIncentive][_treasury];\n\t\tuserRewards[miningIncentive][_treasury] = 0;\n\t\tmesLBR.mint(_treasury, rewardToTreasury);\n\t}\n\n\tfunction getReward(address _rewardPool) external {\n\t\taddress _dlpRewardPool = dlpRewardPool;\n\t\taddress _miningIncentive = miningIncentive;\n\t\tuint256 rewardAmount;\n \n\t\tif (_rewardPool == _dlpRewardPool) {\n\t\t\t_dlpUpdateReward(msg.sender);\n\n\t\t\trewardAmount = userRewards[_dlpRewardPool][msg.sender];\n\t\t\tif (rewardAmount > 0) {\n\t\t\t\tuserRewards[_dlpRewardPool][msg.sender] = 0;\n\t\t\t\tmesLBR.mint(msg.sender, rewardAmount);\n\t\t\t\temit mesLBRRewardClaimed(msg.sender, rewardAmount);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (_rewardPool == _miningIncentive) {\n\t\t\t_lsdUpdateReward(msg.sender);\n\t\t\t_eusdUpdateReward(msg.sender);\n\n\t\t\trewardAmount = userRewards[_miningIncentive][msg.sender];\n\t\t\tif (rewardAmount > 0) {\n\t\t\t\tuserRewards[_miningIncentive][msg.sender] = 0;\n\t\t\t\tmesLBR.mint(msg.sender, rewardAmount);\n\t\t\t\temit mesLBRRewardClaimed(msg.sender, rewardAmount);\n\t\t\t}\n\n\t\t\trewardAmount = userRewards[eUSD][msg.sender];\n\t\t\tif (rewardAmount > 0) {\n\t\t\t\tIERC20 _eUSD = IERC20(eUSD);\n\t\t\t\t// Get actual claim amount, including newly rebased eUSD in this contract\n\t\t\t\tuint256 actualAmount = _eUSD.balanceOf(address(this)) * \n\t\t\t\t\tuserRewards[address(_eUSD)][msg.sender] / totalEUSD;\n\t\t\t\tuserRewards[address(_eUSD)][msg.sender] = 0;\n\t\t\t\ttotalEUSD -= rewardAmount;\n\n\t\t\t\t_eUSD.transfer(msg.sender, actualAmount);\n\t\t\t\temit eUSDRewardClaimed(msg.sender, rewardAmount);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\t}\n\n\tfunction getAllRewards() external {\n\t\taddress _dlpRewardPool = dlpRewardPool;\n\t\taddress _miningIncentive = miningIncentive;\n\t\t// Update dlp & mining global var, dlp user var\n\t\t_dlpUpdateReward(msg.sender);\n\t\t// Update mining user var\n\t\t_updateUserVar(_miningIncentive, msg.sender);\n\t\t// Update eUSD global var & user var\n\t\t_eusdUpdateReward(msg.sender);\n\n\t\tuint256 rewardAmount = (userRewards[_dlpRewardPool][msg.sender] +\n\t\t\tuserRewards[_miningIncentive][msg.sender]);\n\t\tuserRewards[_dlpRewardPool][msg.sender] = 0;\n\t\tuserRewards[_miningIncentive][msg.sender] = 0;\n\t\tmesLBR.mint(msg.sender, rewardAmount);\n\t\temit mesLBRRewardClaimed(msg.sender, rewardAmount);\n\n\t\trewardAmount = userRewards[eUSD][msg.sender];\n\t\tIERC20 _eUSD = IERC20(eUSD);\n\t\t// Get actual claim amount, including newly rebased eUSD in this contract\n\t\tuint256 actualAmount = _eUSD.balanceOf(address(this)) * userRewards[eUSD][msg.sender] / totalEUSD;\n\t\tuserRewards[eUSD][msg.sender] = 0;\n\t\ttotalEUSD -= rewardAmount;\n\t\t_eUSD.transfer(msg.sender, actualAmount);\n\t\temit eUSDRewardClaimed(msg.sender, rewardAmount);\n\t}\n\n\t// ! We can call this function periodically to update reward distributors\n    // Update and distribute the reward to several distributors\n    // Includes:\n    //   - boost reward to mesLBR stakers (1 distributor)\n    //   - treasury reward to vlMatch stakers (1 distributor)\n    //   - protocol revenue to mesLBR stakers (2 distributors)\n    function updateRewardDistributors() public {\n        // !! @modify Code added by Eric 20231030\n        uint256 protocolRevenue = IRewardPool(lybraConfigurator.getProtocolRewardsPool()).earned(address(matchPool));\n\n        // Get peUSD(or peUSD & USDC)\n        // Protocol revenue will first goes to this contract\n        // In lybra protocol revenue cotract, it will give peUSD if it is enough,\n        // if it is not enough, it will give peUSD + altStablecoin.\n        // But it will not tell you the amount of each token.\n        if (protocolRevenue > 0) {\n            IMatchPool(matchPool).claimProtocolRevenue();\n        }\n\n        // Distribute treasury reward part to distributors, for vlMatch staking\n        uint256 rewardToTreasury = userRewards[miningIncentive][treasury];\n        userRewards[miningIncentive][treasury] = 0;\n\n        // !! @modify Code added by Eric 20231030\n        // pendingBoostReward has been updated in the previous \"getReward\" funciton inside \"getAllRewards\"\n        if (pendingBoostReward > 0) {\n            _distributeRewardToDistributors(pendingBoostReward, rewardToTreasury);\n\n            // delete this buffer\n            pendingBoostReward = 0;\n        } else _distributeRewardToDistributors(0, rewardToTreasury);\n    }\n\n    /**\n     * @notice Distribute the reward to corresponding distributor contracts\n     *\n     * @dev    Total mesLBR Reward: 150 = boost reward (50) + treasury reward (100)\n     *\n     *         Boost Reward to:\n     *         1) mesLBR staking (40)\n     *\n     *         Treasury Reward to:\n     *         1) vlMatch staking (10)\n     *\n     *         peUSD / altStablecoin to:\n     *         1) mesLBR staking\n     */\n    function _distributeRewardToDistributors(uint256 _boostReward, uint256 _treasuryReward) internal {\n        // Mint boost reward mesLBR to reward distributor\n        // Reward token: mesLBR\n        // Receiver: mesLBR staking contract\n        address boostReceiver = rewardDistributorFactory.distributors(\n            address(mesLBR),\n            mesLBRStaking\n        );\n        require(boostReceiver != address(0), \"Invalid distributor\");\n        mesLBR.mint(boostReceiver, _boostReward);\n\n        // Transfer treasury reward to reward distributor for vlMatch staking\n        // Reward token: mesLBR\n        // Receiver: vlMatch staking contract\n        address treasuryReceiver = rewardDistributorFactory.distributors(\n            address(mesLBR),\n            vlMatchStaking\n        );\n        require(treasuryReceiver != address(0), \"Invalid distributor\");\n        mesLBR.mint(treasuryReceiver, _treasuryReward);\n\n        // Transfer stablecoin protocol revenue to reward distributor\n        address peUSD = lybraConfigurator.peUSD();\n        address altStablecoin = lybraConfigurator.stableToken();\n\n        uint256 peUSDBalance = IERC20(peUSD).balanceOf(address(this));\n        uint256 altStablecoinBalance = IERC20(altStablecoin).balanceOf(address(this));\n\n        // ! Transfer all peUSD and altStablecoin to their distributors\n        // ! It seems proper for now\n        // ! All peUSD and altStablecoin inside this contract is from protocol revenue\n        // ! --------------------\n        // ! 20240112 Need to ensure the distributor contract exists or we will transfer to zero address\n        // ! If Lybra changes the altStablecoin we need to add a new distributor (no change in this contract)\n        address peUSDReceiver = rewardDistributorFactory.distributors(\n            peUSD,\n            mesLBRStaking\n        );\n        require(peUSDReceiver != address(0), \"No peUSD distributor\");\n        IERC20(peUSD).transfer(peUSDReceiver, peUSDBalance);\n\n        address altStablecoinReceiver = rewardDistributorFactory.distributors(\n            altStablecoin,\n            mesLBRStaking\n        );\n        require(altStablecoinReceiver != address(0), \"No altStablecoin distributor\");\n        IERC20(altStablecoin).transfer(altStablecoinReceiver, altStablecoinBalance);\n\n        emit RewardDistributedToDistributors(_boostReward, _treasuryReward, peUSDBalance, altStablecoinBalance);\n    }\n\n\tfunction _rewardPerToken(address _rewardPool, uint256 _rewardAmount) private view returns (uint256) {\n\t\tuint256 rptStored = rewardPerTokenStored[_rewardPool];\n\t\tuint256 totalToken;\n\t\tif (_rewardPool == dlpRewardPool) totalToken = matchPool.totalStaked();\n\t\t// Support only stETH for version 1\n\t\tif (_rewardPool == miningIncentive || _rewardPool == eUSD) \n\t\t\ttotalToken = matchPool.totalSupplied(address(matchPool.getMintPool()));\n\n\t\treturn totalToken > 0 ? rptStored + _rewardAmount * 1e18 / totalToken : rptStored;\n\t}\n\n\tfunction _earned(\n\t\taddress _rewardPool,\n\t\taddress _account,\n\t\tuint256 _rpt\n\t) private view returns (uint256) {\n\t\tuint256 share;\n\t\tif (_rewardPool == dlpRewardPool) share = matchPool.staked(_account);\n\t\t// Support only stETH for version 1\n\t\tif (_rewardPool == miningIncentive || _rewardPool == eUSD) \n\t\t\tshare = matchPool.supplied(address(matchPool.getMintPool()), _account);\n\n\t\treturn share * (_rpt - userRewardsPerTokenPaid[_rewardPool][_account]) / 1e18 + \n\t\t\tuserRewards[_rewardPool][_account];\n\t}\n\n\tfunction _dlpUpdateReward(address _account) private {\n\t\taddress _dlpRewardPool = dlpRewardPool;\n\t\taddress _miningIncentive = miningIncentive;\n\n\t\t// dLP stake pool does not have boost reward\n\t\t(uint256 dlpNormal,) = _updateGlobalVar(_dlpRewardPool);\n\t\t(uint256 lsdNormal, uint256 lsdBoost) = _updateGlobalVar(_miningIncentive);\n\n\t\tif (lsdNormal > 0) {\n\t\t\t(uint256 toStaker, uint256 toSupplier) = _calcRewardShares(lsdNormal);\n\t\t\tdlpNormal += toStaker;\n\n\t\t\trewardPerTokenStored[_miningIncentive] = _rewardPerToken(_miningIncentive, toSupplier);\n\n\t\t\t// dLP stake pool does not have boost reward\n\t        pendingBoostReward += lsdBoost;\n\t\t}\n\n\t\tif (dlpNormal > 0) rewardPerTokenStored[_dlpRewardPool] = _rewardPerToken(_dlpRewardPool, dlpNormal);\n\n\t\t_updateUserVar(_dlpRewardPool, _account);\n\t}\n\n\tfunction _lsdUpdateReward(address _account) private {\n\t\taddress _dlpRewardPool = dlpRewardPool;\n\t\taddress _miningIncentive = miningIncentive;\n\n\t\t// esLBR earned from Lybra eUSD mining incentive\n        // !! @modify Code added by Eric 20231030\n        (uint256 lsdNormal, uint256 lsdBoost) = _updateGlobalVar(_miningIncentive);\n\n\t\tif (lsdNormal > 0) {\n\t\t\t(uint256 toStaker, uint256 toSupplier) = _calcRewardShares(lsdNormal);\n\n\t\t\trewardPerTokenStored[_dlpRewardPool] = _rewardPerToken(_dlpRewardPool, toStaker);\n\t\t\trewardPerTokenStored[_miningIncentive] = _rewardPerToken(_miningIncentive, toSupplier);\n\n\t\t\t// !! @modify Code added by Eric 20231030\n\t        // !! @modify Code moved by Eric 20231228\n\t        pendingBoostReward += lsdBoost;\n\t\t}\n\n\t\t_updateUserVar(_miningIncentive, _account);\n\t}\n\n\tfunction _eusdUpdateReward(address _account) private {\n\t\taddress _eUSD = eUSD;\n\t\tuint256 eusdEarned = matchPool.claimRebase();\n\t\tif (eusdEarned > 0) {\n\t\t\ttotalEUSD += eusdEarned;\n\t\t\trewardPerTokenStored[_eUSD] = _rewardPerToken(_eUSD, eusdEarned);\n\t\t}\n\n\t\tif (_account == address(0)) return;\n\n\t\tuint256 rpt = rewardPerTokenStored[_eUSD];\n\t\t(uint256 borrowedAmount,,,) = matchPool.borrowed(address(matchPool.getMintPool()), _account);\n\t\tif (borrowedAmount == 0) userRewards[_eUSD][_account] = _earned(_eUSD, _account, rpt);\n\t\t\t// Users who borrowed eUSD will not share rebase reward\n\t\telse userRewards[_eUSD][treasury] += (_earned(_eUSD, _account, rpt) - userRewards[_eUSD][_account]);\n\n\t\tuserRewardsPerTokenPaid[_eUSD][_account] = rpt;\n\t}\n\n\t/**\n\t * @dev Update variables for Lybra reward calculation\n\t */\n\tfunction _updateGlobalVar(address _rewardPool) private returns (uint256, uint256) {\n\t\t(\n        \tuint256 normalReward, \n        \tuint256 lybraRpt, \n\t\t\tuint256 boostReward, \n        \tuint256 lybraEarned\n        ) = earnedSinceLastUpdate(_rewardPool);\n\t\trewardPerTokenPaid[_rewardPool] = lybraRpt;\n\t\tearnedPaid[_rewardPool] = lybraEarned;\n\n\t\treturn (normalReward, boostReward);\n\t}\n\n\t/**\n\t * @dev Update variables for user reward calculation\n\t */\n\tfunction _updateUserVar(address _rewardPool, address _account) private {\n\t\tif (_account == address(0)) return;\n\t\tuint256 rpt = rewardPerTokenStored[_rewardPool];\n\t\tuserRewards[_rewardPool][_account] = _earned(_rewardPool, _account, rpt);\n\t\tuserRewardsPerTokenPaid[_rewardPool][_account] = rpt;\n\t}\n\n\t/**\n\t * @dev Divide mining reward to appropriate shares for treasury, stakers, suppliers\n\t */\n\tfunction _calcRewardShares(uint256 _rewardAmount) private returns (\n\t\tuint256 toStaker,\n\t\tuint256 toSupplier\n\t) {\n\t\tuint256 toTreasury = _rewardAmount * treasuryShare / 100;\n\t\tif (toTreasury > 0) userRewards[miningIncentive][treasury] += toTreasury;\n\t\t// esLBR reward from mining incentive given to dlp stakers\n\t\ttoStaker = _rewardAmount * stakerShare / 100;\n\t\t// esLBR reward from mining incentive given to stETH suppliers\n\t\ttoSupplier = _rewardAmount - toTreasury - toStaker;\n\t}\n}\n"
      }
    },
    "settings": {
      "metadata": {
        "bytecodeHash": "none",
        "useLiteralContent": true
      },
      "optimizer": {
        "enabled": true,
        "runs": 800
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}