creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./OwnableUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\n    function __Ownable2Step_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable2Step_init_unchained() internal onlyInitializing {\n    }\n    address private _pendingOwner;\n\n    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Returns the address of the pending owner.\n     */\n    function pendingOwner() public view virtual returns (address) {\n        return _pendingOwner;\n    }\n\n    /**\n     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual override onlyOwner {\n        _pendingOwner = newOwner;\n        emit OwnershipTransferStarted(owner(), newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual override {\n        delete _pendingOwner;\n        super._transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev The new owner accepts the ownership transfer.\n     */\n    function acceptOwnership() public virtual {\n        address sender = _msgSender();\n        require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n        _transferOwnership(sender);\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/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/security/PausableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    function __Pausable_init() internal onlyInitializing {\n        __Pausable_init_unchained();\n    }\n\n    function __Pausable_init_unchained() internal onlyInitializing {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        require(!paused(), \"Pausable: paused\");\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        require(paused(), \"Pausable: not paused\");\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\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/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/access/IAccessControl.sol": {
        "content": "// 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 IAccessControl {\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"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\n\nimport \"./IAccessControlManagerV8.sol\";\n\n/**\n * @title AccessControlledV8\n * @author Venus\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\n */\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\n    /// @notice Access control manager contract\n    IAccessControlManagerV8 private _accessControlManager;\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    /// @notice Emitted when access control manager contract address is changed\n    event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\n\n    /// @notice Thrown when the action is prohibited by AccessControlManager\n    error Unauthorized(address sender, address calledContract, string methodSignature);\n\n    function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\n        __Ownable2Step_init();\n        __AccessControlled_init_unchained(accessControlManager_);\n    }\n\n    function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\n        _setAccessControlManager(accessControlManager_);\n    }\n\n    /**\n     * @notice Sets the address of AccessControlManager\n     * @dev Admin function to set address of AccessControlManager\n     * @param accessControlManager_ The new address of the AccessControlManager\n     * @custom:event Emits NewAccessControlManager event\n     * @custom:access Only Governance\n     */\n    function setAccessControlManager(address accessControlManager_) external onlyOwner {\n        _setAccessControlManager(accessControlManager_);\n    }\n\n    /**\n     * @notice Returns the address of the access control manager contract\n     */\n    function accessControlManager() external view returns (IAccessControlManagerV8) {\n        return _accessControlManager;\n    }\n\n    /**\n     * @dev Internal function to set address of AccessControlManager\n     * @param accessControlManager_ The new address of the AccessControlManager\n     */\n    function _setAccessControlManager(address accessControlManager_) internal {\n        require(address(accessControlManager_) != address(0), \"invalid acess control manager address\");\n        address oldAccessControlManager = address(_accessControlManager);\n        _accessControlManager = IAccessControlManagerV8(accessControlManager_);\n        emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\n    }\n\n    /**\n     * @notice Reverts if the call is not allowed by AccessControlManager\n     * @param signature Method signature\n     */\n    function _checkAccessAllowed(string memory signature) internal view {\n        bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\n\n        if (!isAllowedToCall) {\n            revert Unauthorized(msg.sender, address(this), signature);\n        }\n    }\n}\n"
      },
      "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport \"@openzeppelin/contracts/access/IAccessControl.sol\";\n\n/**\n * @title IAccessControlManagerV8\n * @author Venus\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\n */\ninterface IAccessControlManagerV8 is IAccessControl {\n    function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\n\n    function revokeCallPermission(\n        address contractAddress,\n        string calldata functionSig,\n        address accountToRevoke\n    ) external;\n\n    function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\n\n    function hasPermission(\n        address account,\n        address contractAddress,\n        string calldata functionSig\n    ) external view returns (bool);\n}\n"
      },
      "@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\ninterface OracleInterface {\n    function getPrice(address asset) external view returns (uint256);\n}\n\ninterface ResilientOracleInterface is OracleInterface {\n    function updatePrice(address vToken) external;\n\n    function updateAssetPrice(address asset) external;\n\n    function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface TwapInterface is OracleInterface {\n    function updateTwap(address asset) external returns (uint256);\n}\n\ninterface BoundValidatorInterface {\n    function validatePriceWithAnchorPrice(\n        address asset,\n        uint256 reporterPrice,\n        uint256 anchorPrice\n    ) external view returns (bool);\n}\n"
      },
      "@venusprotocol/oracle/contracts/interfaces/VBep20Interface.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\ninterface VBep20Interface is IERC20Metadata {\n    /**\n     * @notice Underlying asset for this VToken\n     */\n    function underlying() external view returns (address);\n}\n"
      },
      "@venusprotocol/oracle/contracts/ResilientOracle.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\n// SPDX-FileCopyrightText: 2022 Venus\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"./interfaces/VBep20Interface.sol\";\nimport \"./interfaces/OracleInterface.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\n\n/**\n * @title ResilientOracle\n * @author Venus\n * @notice The Resilient Oracle is the main contract that the protocol uses to fetch prices of assets.\n * \n * DeFi protocols are vulnerable to price oracle failures including oracle manipulation and incorrectly\n * reported prices. If only one oracle is used, this creates a single point of failure and opens a vector\n * for attacking the protocol.\n * \n * The Resilient Oracle uses multiple sources and fallback mechanisms to provide accurate prices and protect\n * the protocol from oracle attacks. Currently it includes integrations with Chainlink, Pyth, Binance Oracle\n * and TWAP (Time-Weighted Average Price) oracles. TWAP uses PancakeSwap as the on-chain price source.\n * \n * For every market (vToken) we configure the main, pivot and fallback oracles. The oracles are configured per \n * vToken's underlying asset address. The main oracle oracle is the most trustworthy price source, the pivot \n * oracle is used as a loose sanity checker and the fallback oracle is used as a backup price source. \n * \n * To validate prices returned from two oracles, we use an upper and lower bound ratio that is set for every\n * market. The upper bound ratio represents the deviation between reported price (the price that’s being\n * validated) and the anchor price (the price we are validating against) above which the reported price will\n * be invalidated. The lower bound ratio presents the deviation between reported price and anchor price below\n * which the reported price will be invalidated. So for oracle price to be considered valid the below statement\n * should be true:\n\n```\nanchorRatio = anchorPrice/reporterPrice\nisValid = anchorRatio <= upperBoundAnchorRatio && anchorRatio >= lowerBoundAnchorRatio\n```\n\n * In most cases, Chainlink is used as the main oracle, TWAP or Pyth oracles are used as the pivot oracle depending\n * on which supports the given market and Binance oracle is used as the fallback oracle. For some markets we may\n * use Pyth or TWAP as the main oracle if the token price is not supported by Chainlink or Binance oracles. \n * \n * For a fetched price to be valid it must be positive and not stagnant. If the price is invalid then we consider the\n * oracle to be stagnant and treat it like it's disabled.\n */\ncontract ResilientOracle is PausableUpgradeable, AccessControlledV8, ResilientOracleInterface {\n    /**\n     * @dev Oracle roles:\n     * **main**: The most trustworthy price source\n     * **pivot**: Price oracle used as a loose sanity checker\n     * **fallback**: The backup source when main oracle price is invalidated\n     */\n    enum OracleRole {\n        MAIN,\n        PIVOT,\n        FALLBACK\n    }\n\n    struct TokenConfig {\n        /// @notice asset address\n        address asset;\n        /// @notice `oracles` stores the oracles based on their role in the following order:\n        /// [main, pivot, fallback],\n        /// It can be indexed with the corresponding enum OracleRole value\n        address[3] oracles;\n        /// @notice `enableFlagsForOracles` stores the enabled state\n        /// for each oracle in the same order as `oracles`\n        bool[3] enableFlagsForOracles;\n    }\n\n    uint256 public constant INVALID_PRICE = 0;\n\n    /// @notice Native market address\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    address public immutable nativeMarket;\n\n    /// @notice VAI address\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    address public immutable vai;\n\n    /// @notice Set this as asset address for Native token on each chain.This is the underlying for vBNB (on bsc)\n    /// and can serve as any underlying asset of a market that supports native tokens\n    address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n    /// @notice Bound validator contract address\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    BoundValidatorInterface public immutable boundValidator;\n\n    mapping(address => TokenConfig) private tokenConfigs;\n\n    event TokenConfigAdded(\n        address indexed asset,\n        address indexed mainOracle,\n        address indexed pivotOracle,\n        address fallbackOracle\n    );\n\n    /// Event emitted when an oracle is set\n    event OracleSet(address indexed asset, address indexed oracle, uint256 indexed role);\n\n    /// Event emitted when an oracle is enabled or disabled\n    event OracleEnabled(address indexed asset, uint256 indexed role, bool indexed enable);\n\n    /**\n     * @notice Checks whether an address is null or not\n     */\n    modifier notNullAddress(address someone) {\n        if (someone == address(0)) revert(\"can't be zero address\");\n        _;\n    }\n\n    /**\n     * @notice Checks whether token config exists by checking whether asset is null address\n     * @dev address can't be null, so it's suitable to be used to check the validity of the config\n     * @param asset asset address\n     */\n    modifier checkTokenConfigExistence(address asset) {\n        if (tokenConfigs[asset].asset == address(0)) revert(\"token config must exist\");\n        _;\n    }\n\n    /// @notice Constructor for the implementation contract. Sets immutable variables.\n    /// @dev nativeMarketAddress can be address(0) if on the chain we do not support native market\n    ///      (e.g vETH on ethereum would not be supported, only vWETH)\n    /// @param nativeMarketAddress The address of a native market (for bsc it would be vBNB address)\n    /// @param vaiAddress The address of the VAI token (if there is VAI on the deployed chain).\n    ///          Set to address(0) of VAI is not existent.\n    /// @param _boundValidator Address of the bound validator contract\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor(\n        address nativeMarketAddress,\n        address vaiAddress,\n        BoundValidatorInterface _boundValidator\n    ) notNullAddress(address(_boundValidator)) {\n        nativeMarket = nativeMarketAddress;\n        vai = vaiAddress;\n        boundValidator = _boundValidator;\n\n        _disableInitializers();\n    }\n\n    /**\n     * @notice Initializes the contract admin and sets the BoundValidator contract address\n     * @param accessControlManager_ Address of the access control manager contract\n     */\n    function initialize(address accessControlManager_) external initializer {\n        __AccessControlled_init(accessControlManager_);\n        __Pausable_init();\n    }\n\n    /**\n     * @notice Pauses oracle\n     * @custom:access Only Governance\n     */\n    function pause() external {\n        _checkAccessAllowed(\"pause()\");\n        _pause();\n    }\n\n    /**\n     * @notice Unpauses oracle\n     * @custom:access Only Governance\n     */\n    function unpause() external {\n        _checkAccessAllowed(\"unpause()\");\n        _unpause();\n    }\n\n    /**\n     * @notice Batch sets token configs\n     * @param tokenConfigs_ Token config array\n     * @custom:access Only Governance\n     * @custom:error Throws a length error if the length of the token configs array is 0\n     */\n    function setTokenConfigs(TokenConfig[] memory tokenConfigs_) external {\n        if (tokenConfigs_.length == 0) revert(\"length can't be 0\");\n        uint256 numTokenConfigs = tokenConfigs_.length;\n        for (uint256 i; i < numTokenConfigs; ) {\n            setTokenConfig(tokenConfigs_[i]);\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    /**\n     * @notice Sets oracle for a given asset and role.\n     * @dev Supplied asset **must** exist and main oracle may not be null\n     * @param asset Asset address\n     * @param oracle Oracle address\n     * @param role Oracle role\n     * @custom:access Only Governance\n     * @custom:error Null address error if main-role oracle address is null\n     * @custom:error NotNullAddress error is thrown if asset address is null\n     * @custom:error TokenConfigExistance error is thrown if token config is not set\n     * @custom:event Emits OracleSet event with asset address, oracle address and role of the oracle for the asset\n     */\n    function setOracle(\n        address asset,\n        address oracle,\n        OracleRole role\n    ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n        _checkAccessAllowed(\"setOracle(address,address,uint8)\");\n        if (oracle == address(0) && role == OracleRole.MAIN) revert(\"can't set zero address to main oracle\");\n        tokenConfigs[asset].oracles[uint256(role)] = oracle;\n        emit OracleSet(asset, oracle, uint256(role));\n    }\n\n    /**\n     * @notice Enables/ disables oracle for the input asset. Token config for the input asset **must** exist\n     * @dev Configuration for the asset **must** already exist and the asset cannot be 0 address\n     * @param asset Asset address\n     * @param role Oracle role\n     * @param enable Enabled boolean of the oracle\n     * @custom:access Only Governance\n     * @custom:error NotNullAddress error is thrown if asset address is null\n     * @custom:error TokenConfigExistance error is thrown if token config is not set\n     */\n    function enableOracle(\n        address asset,\n        OracleRole role,\n        bool enable\n    ) external notNullAddress(asset) checkTokenConfigExistence(asset) {\n        _checkAccessAllowed(\"enableOracle(address,uint8,bool)\");\n        tokenConfigs[asset].enableFlagsForOracles[uint256(role)] = enable;\n        emit OracleEnabled(asset, uint256(role), enable);\n    }\n\n    /**\n     * @notice Updates the TWAP pivot oracle price.\n     * @dev This function should always be called before calling getUnderlyingPrice\n     * @param vToken vToken address\n     */\n    function updatePrice(address vToken) external override {\n        address asset = _getUnderlyingAsset(vToken);\n        (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n        if (pivotOracle != address(0) && pivotOracleEnabled) {\n            //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n            try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n        }\n    }\n\n    /**\n     * @notice Updates the pivot oracle price. Currently using TWAP\n     * @dev This function should always be called before calling getPrice\n     * @param asset asset address\n     */\n    function updateAssetPrice(address asset) external {\n        (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n        if (pivotOracle != address(0) && pivotOracleEnabled) {\n            //if pivot oracle is not TwapOracle it will revert so we need to catch the revert\n            try TwapInterface(pivotOracle).updateTwap(asset) {} catch {}\n        }\n    }\n\n    /**\n     * @dev Gets token config by asset address\n     * @param asset asset address\n     * @return tokenConfig Config for the asset\n     */\n    function getTokenConfig(address asset) external view returns (TokenConfig memory) {\n        return tokenConfigs[asset];\n    }\n\n    /**\n     * @notice Gets price of the underlying asset for a given vToken. Validation flow:\n     * - Check if the oracle is paused globally\n     * - Validate price from main oracle against pivot oracle\n     * - Validate price from fallback oracle against pivot oracle if the first validation failed\n     * - Validate price from main oracle against fallback oracle if the second validation failed\n     * In the case that the pivot oracle is not available but main price is available and validation is successful,\n     * main oracle price is returned.\n     * @param vToken vToken address\n     * @return price USD price in scaled decimal places.\n     * @custom:error Paused error is thrown when resilent oracle is paused\n     * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n     */\n    function getUnderlyingPrice(address vToken) external view override returns (uint256) {\n        if (paused()) revert(\"resilient oracle is paused\");\n\n        address asset = _getUnderlyingAsset(vToken);\n        return _getPrice(asset);\n    }\n\n    /**\n     * @notice Gets price of the asset\n     * @param asset asset address\n     * @return price USD price in scaled decimal places.\n     * @custom:error Paused error is thrown when resilent oracle is paused\n     * @custom:error Invalid resilient oracle price error is thrown if fetched prices from oracle is invalid\n     */\n    function getPrice(address asset) external view override returns (uint256) {\n        if (paused()) revert(\"resilient oracle is paused\");\n        return _getPrice(asset);\n    }\n\n    /**\n     * @notice Sets/resets single token configs.\n     * @dev main oracle **must not** be a null address\n     * @param tokenConfig Token config struct\n     * @custom:access Only Governance\n     * @custom:error NotNullAddress is thrown if asset address is null\n     * @custom:error NotNullAddress is thrown if main-role oracle address for asset is null\n     * @custom:event Emits TokenConfigAdded event when the asset config is set successfully by the authorized account\n     */\n    function setTokenConfig(\n        TokenConfig memory tokenConfig\n    ) public notNullAddress(tokenConfig.asset) notNullAddress(tokenConfig.oracles[uint256(OracleRole.MAIN)]) {\n        _checkAccessAllowed(\"setTokenConfig(TokenConfig)\");\n\n        tokenConfigs[tokenConfig.asset] = tokenConfig;\n        emit TokenConfigAdded(\n            tokenConfig.asset,\n            tokenConfig.oracles[uint256(OracleRole.MAIN)],\n            tokenConfig.oracles[uint256(OracleRole.PIVOT)],\n            tokenConfig.oracles[uint256(OracleRole.FALLBACK)]\n        );\n    }\n\n    /**\n     * @notice Gets oracle and enabled status by asset address\n     * @param asset asset address\n     * @param role Oracle role\n     * @return oracle Oracle address based on role\n     * @return enabled Enabled flag of the oracle based on token config\n     */\n    function getOracle(address asset, OracleRole role) public view returns (address oracle, bool enabled) {\n        oracle = tokenConfigs[asset].oracles[uint256(role)];\n        enabled = tokenConfigs[asset].enableFlagsForOracles[uint256(role)];\n    }\n\n    function _getPrice(address asset) internal view returns (uint256) {\n        uint256 pivotPrice = INVALID_PRICE;\n\n        // Get pivot oracle price, Invalid price if not available or error\n        (address pivotOracle, bool pivotOracleEnabled) = getOracle(asset, OracleRole.PIVOT);\n        if (pivotOracleEnabled && pivotOracle != address(0)) {\n            try OracleInterface(pivotOracle).getPrice(asset) returns (uint256 pricePivot) {\n                pivotPrice = pricePivot;\n            } catch {}\n        }\n\n        // Compare main price and pivot price, return main price and if validation was successful\n        // note: In case pivot oracle is not available but main price is available and\n        // validation is successful, the main oracle price is returned.\n        (uint256 mainPrice, bool validatedPivotMain) = _getMainOraclePrice(\n            asset,\n            pivotPrice,\n            pivotOracleEnabled && pivotOracle != address(0)\n        );\n        if (mainPrice != INVALID_PRICE && validatedPivotMain) return mainPrice;\n\n        // Compare fallback and pivot if main oracle comparision fails with pivot\n        // Return fallback price when fallback price is validated successfully with pivot oracle\n        (uint256 fallbackPrice, bool validatedPivotFallback) = _getFallbackOraclePrice(asset, pivotPrice);\n        if (fallbackPrice != INVALID_PRICE && validatedPivotFallback) return fallbackPrice;\n\n        // Lastly compare main price and fallback price\n        if (\n            mainPrice != INVALID_PRICE &&\n            fallbackPrice != INVALID_PRICE &&\n            boundValidator.validatePriceWithAnchorPrice(asset, mainPrice, fallbackPrice)\n        ) {\n            return mainPrice;\n        }\n\n        revert(\"invalid resilient oracle price\");\n    }\n\n    /**\n     * @notice Gets a price for the provided asset\n     * @dev This function won't revert when price is 0, because the fallback oracle may still be\n     * able to fetch a correct price\n     * @param asset asset address\n     * @param pivotPrice Pivot oracle price\n     * @param pivotEnabled If pivot oracle is not empty and enabled\n     * @return price USD price in scaled decimals\n     * e.g. asset decimals is 8 then price is returned as 10**18 * 10**(18-8) = 10**28 decimals\n     * @return pivotValidated Boolean representing if the validation of main oracle price\n     * and pivot oracle price were successful\n     * @custom:error Invalid price error is thrown if main oracle fails to fetch price of the asset\n     * @custom:error Invalid price error is thrown if main oracle is not enabled or main oracle\n     * address is null\n     */\n    function _getMainOraclePrice(\n        address asset,\n        uint256 pivotPrice,\n        bool pivotEnabled\n    ) internal view returns (uint256, bool) {\n        (address mainOracle, bool mainOracleEnabled) = getOracle(asset, OracleRole.MAIN);\n        if (mainOracleEnabled && mainOracle != address(0)) {\n            try OracleInterface(mainOracle).getPrice(asset) returns (uint256 mainOraclePrice) {\n                if (!pivotEnabled) {\n                    return (mainOraclePrice, true);\n                }\n                if (pivotPrice == INVALID_PRICE) {\n                    return (mainOraclePrice, false);\n                }\n                return (\n                    mainOraclePrice,\n                    boundValidator.validatePriceWithAnchorPrice(asset, mainOraclePrice, pivotPrice)\n                );\n            } catch {\n                return (INVALID_PRICE, false);\n            }\n        }\n\n        return (INVALID_PRICE, false);\n    }\n\n    /**\n     * @dev This function won't revert when the price is 0 because getPrice checks if price is > 0\n     * @param asset asset address\n     * @return price USD price in 18 decimals\n     * @return pivotValidated Boolean representing if the validation of fallback oracle price\n     * and pivot oracle price were successfull\n     * @custom:error Invalid price error is thrown if fallback oracle fails to fetch price of the asset\n     * @custom:error Invalid price error is thrown if fallback oracle is not enabled or fallback oracle\n     * address is null\n     */\n    function _getFallbackOraclePrice(address asset, uint256 pivotPrice) private view returns (uint256, bool) {\n        (address fallbackOracle, bool fallbackEnabled) = getOracle(asset, OracleRole.FALLBACK);\n        if (fallbackEnabled && fallbackOracle != address(0)) {\n            try OracleInterface(fallbackOracle).getPrice(asset) returns (uint256 fallbackOraclePrice) {\n                if (pivotPrice == INVALID_PRICE) {\n                    return (fallbackOraclePrice, false);\n                }\n                return (\n                    fallbackOraclePrice,\n                    boundValidator.validatePriceWithAnchorPrice(asset, fallbackOraclePrice, pivotPrice)\n                );\n            } catch {\n                return (INVALID_PRICE, false);\n            }\n        }\n\n        return (INVALID_PRICE, false);\n    }\n\n    /**\n     * @dev This function returns the underlying asset of a vToken\n     * @param vToken vToken address\n     * @return asset underlying asset address\n     */\n    function _getUnderlyingAsset(address vToken) private view notNullAddress(vToken) returns (address asset) {\n        if (vToken == nativeMarket) {\n            asset = NATIVE_TOKEN_ADDR;\n        } else if (vToken == vai) {\n            asset = vai;\n        } else {\n            asset = VBep20Interface(vToken).underlying();\n        }\n    }\n}\n"
      },
      "@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/**\n * @title MaxLoopsLimitHelper\n * @author Venus\n * @notice Abstract contract used to avoid collection with too many items that would generate gas errors and DoS.\n */\nabstract contract MaxLoopsLimitHelper {\n    // Limit for the loops to avoid the DOS\n    uint256 public maxLoopsLimit;\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    /// @notice Emitted when max loops limit is set\n    event MaxLoopsLimitUpdated(uint256 oldMaxLoopsLimit, uint256 newmaxLoopsLimit);\n\n    /// @notice Thrown an error on maxLoopsLimit exceeds for any loop\n    error MaxLoopsLimitExceeded(uint256 loopsLimit, uint256 requiredLoops);\n\n    /**\n     * @notice Set the limit for the loops can iterate to avoid the DOS\n     * @param limit Limit for the max loops can execute at a time\n     */\n    function _setMaxLoopsLimit(uint256 limit) internal {\n        require(limit > maxLoopsLimit, \"Comptroller: Invalid maxLoopsLimit\");\n\n        uint256 oldMaxLoopsLimit = maxLoopsLimit;\n        maxLoopsLimit = limit;\n\n        emit MaxLoopsLimitUpdated(oldMaxLoopsLimit, limit);\n    }\n\n    /**\n     * @notice Compare the maxLoopsLimit with number of the times loop iterate\n     * @param len Length of the loops iterate\n     * @custom:error MaxLoopsLimitExceeded error is thrown when loops length exceeds maxLoopsLimit\n     */\n    function _ensureMaxLoops(uint256 len) internal view {\n        if (len > maxLoopsLimit) {\n            revert MaxLoopsLimitExceeded(maxLoopsLimit, len);\n        }\n    }\n}\n"
      },
      "@venusprotocol/solidity-utilities/contracts/validators.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\nerror ZeroAddressNotAllowed();\n\n/// @notice Thrown if the supplied value is 0 where it is not allowed\nerror ZeroValueNotAllowed();\n\n/// @notice Checks if the provided address is nonzero, reverts otherwise\n/// @param address_ Address to check\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\nfunction ensureNonzeroAddress(address address_) pure {\n    if (address_ == address(0)) {\n        revert ZeroAddressNotAllowed();\n    }\n}\n\n/// @notice Checks if the provided value is nonzero, reverts otherwise\n/// @param value_ Value to check\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\nfunction ensureNonzeroValue(uint256 value_) pure {\n    if (value_ == 0) {\n        revert ZeroValueNotAllowed();\n    }\n}\n"
      },
      "contracts/Interfaces/IConverterNetwork.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport { IAbstractTokenConverter } from \"../TokenConverter/IAbstractTokenConverter.sol\";\n\n/**\n * @title IConverterNetwork\n * @author Venus\n * @notice Interface implemented by `ConverterNetwork`.\n */\ninterface IConverterNetwork {\n    /// @notice Adds new converter to the array\n    /// @param _tokenConverter Address of the token converter\n    function addTokenConverter(IAbstractTokenConverter _tokenConverter) external;\n\n    /// @notice Removes converter from the array\n    /// @param _tokenConverter Address of the token converter\n    function removeTokenConverter(IAbstractTokenConverter _tokenConverter) external;\n\n    /// @notice Used to get the array of converters supporting conversions, arranged in descending order based on token balances\n    /// @param _tokenAddressIn Address of tokenIn\n    /// @param _tokenAddressOut Address of tokenOut\n    /// @return converters Array of the conveters on the basis of the tokens pair\n    /// @return convertersBalance Array of balances with respect to token out\n    function findTokenConverters(address _tokenAddressIn, address _tokenAddressOut)\n        external\n        returns (address[] memory converters, uint256[] memory convertersBalance);\n\n    /// @notice Used to get the array of converters supporting conversions, arranged in descending order based on token balances\n    /// @param _tokenAddressIn Address of tokenIn\n    /// @param _tokenAddressOut Address of tokenOut\n    /// @return converters Array of the conveters on the basis of the tokens pair\n    /// @return convertersBalance Array of balances with respect to token out\n    function findTokenConvertersForConverters(address _tokenAddressIn, address _tokenAddressOut)\n        external\n        returns (address[] memory converters, uint256[] memory convertersBalance);\n\n    /// @notice This function returns the array containing all the converters addresses\n    /// @return Array containing all the converters addresses\n    function getAllConverters() external view returns (IAbstractTokenConverter[] memory);\n\n    /// @notice This function checks for given address is converter or not\n    /// @param _tokenConverter Address of the token converter\n    /// @return boolean true if given address is converter otherwise false\n    function isTokenConverter(address _tokenConverter) external view returns (bool);\n}\n"
      },
      "contracts/TokenConverter/ConverterNetwork.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { AccessControlledV8 } from \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport { MaxLoopsLimitHelper } from \"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\n\nimport { sort } from \"../Utils/ArrayHelpers.sol\";\nimport { IAbstractTokenConverter } from \"./IAbstractTokenConverter.sol\";\nimport { IConverterNetwork } from \"../Interfaces/IConverterNetwork.sol\";\n\n/// @title ConverterNetwork\n/// @author Venus\n/// @notice ConverterNetwork keeps track of all the converters and is used to fetch valid converters which provide conversions according to token addresses provided\n/// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion\ncontract ConverterNetwork is IConverterNetwork, AccessControlledV8, MaxLoopsLimitHelper {\n    /// @notice Array holding all the converters\n    IAbstractTokenConverter[] public allConverters;\n\n    /// @notice Emitted when new converter is added\n    event ConverterAdded(address indexed converter);\n\n    /// @notice Emitted when converter is removed\n    event ConverterRemoved(address indexed converter);\n\n    /// @notice Error thrown when converter already exists\n    error ConverterAlreadyExists();\n\n    /// @notice Error thrown converter does not exist\n    error ConverterDoesNotExist();\n\n    /// @notice Error thrown when converter address is invalid\n    error InvalidTokenConverterAddress();\n\n    /// @notice Error thrown when loops limit is invalid\n    error InvalidMaxLoopsLimit(uint256 loopsLimit);\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        // Note that the contract is upgradeable. Use initialize() or reinitializers\n        // to set the state variables.\n        _disableInitializers();\n    }\n\n    /// @notice ConverterNetwork initializer\n    /// @param _accessControlManager The address of ACM contract\n    /// @param _loopsLimit Limit for the loops in the contract to avoid DOS\n    /// @custom:event ConverterAdded is emitted for each converter added on success\n    /// @custom:error InvalidMaxLoopsLimit is thrown when when loops limit is invalid\n    function initialize(address _accessControlManager, uint256 _loopsLimit) external initializer {\n        ensureNonzeroAddress(_accessControlManager);\n        __AccessControlled_init(_accessControlManager);\n\n        if (_loopsLimit >= type(uint128).max) revert InvalidMaxLoopsLimit(_loopsLimit);\n        _setMaxLoopsLimit(_loopsLimit);\n    }\n\n    /**\n     * @notice Set the limit for the loops can iterate to avoid the DOS\n     * @param limit Limit for the max loops can execute at a time\n     * @custom:error InvalidMaxLoopsLimit is thrown when when loops limit is invalid\n     * @custom:access Only owner\n     */\n    function setMaxLoopsLimit(uint256 limit) external onlyOwner {\n        if (limit >= type(uint128).max) revert InvalidMaxLoopsLimit(limit);\n        _setMaxLoopsLimit(limit);\n    }\n\n    /// @notice Adds new converter to the array\n    /// @param _tokenConverter Address of the token converter\n    /// @custom:event ConverterAdded is emitted on success\n    /// @custom:access Only Governance\n    function addTokenConverter(IAbstractTokenConverter _tokenConverter) external {\n        _checkAccessAllowed(\"addTokenConverter(address)\");\n        _addTokenConverter(_tokenConverter);\n    }\n\n    /// @notice Removes converter from the array\n    /// @param _tokenConverter Address of the token converter\n    /// @custom:error ConverterDoesNotExist is thrown when converter to remove does not exist\n    /// @custom:event ConverterRemoved is emitted on success\n    /// @custom:access Only Governance\n    function removeTokenConverter(IAbstractTokenConverter _tokenConverter) external {\n        _checkAccessAllowed(\"removeTokenConverter(address)\");\n\n        // Find the index of the converter in the array\n        uint128 indexToRemove = _findConverterIndex(_tokenConverter);\n\n        // Ensure that the converter exists in the array\n        if (indexToRemove == type(uint128).max) revert ConverterDoesNotExist();\n\n        // Swap the element to remove with the last element\n        allConverters[indexToRemove] = allConverters[allConverters.length - 1];\n\n        // Remove the last element (which is now a duplicate)\n        allConverters.pop();\n\n        emit ConverterRemoved(address(_tokenConverter));\n    }\n\n    /// @notice Used to get the array of converters supporting conversions, arranged in descending order based on token balances\n    /// It will return the converters which are open to users for conversion\n    /// @param _tokenAddressIn Address of tokenIn\n    /// @param _tokenAddressOut Address of tokenOut\n    /// @return converters Array of the conveters on the basis of the tokens pair\n    /// @return convertersBalance Array of balances with respect to token out\n    function findTokenConverters(address _tokenAddressIn, address _tokenAddressOut)\n        external\n        returns (address[] memory converters, uint256[] memory convertersBalance)\n    {\n        (converters, convertersBalance) = _findTokenConverters(_tokenAddressIn, _tokenAddressOut, false);\n    }\n\n    /// @notice Used to get the array of converters supporting conversions, arranged in descending order based on token balances\n    /// It will return the converters which are open to converters for conversion.\n    /// @param _tokenAddressIn Address of tokenIn\n    /// @param _tokenAddressOut Address of tokenOut\n    /// @return converters Array of the conveters on the basis of the tokens pair\n    /// @return convertersBalance Array of balances with respect to token out\n    function findTokenConvertersForConverters(address _tokenAddressIn, address _tokenAddressOut)\n        external\n        returns (address[] memory converters, uint256[] memory convertersBalance)\n    {\n        (converters, convertersBalance) = _findTokenConverters(_tokenAddressIn, _tokenAddressOut, true);\n    }\n\n    /// @notice This function returns the array containing all the converters addresses\n    /// @return converters Array containing all the converters addresses\n    function getAllConverters() external view returns (IAbstractTokenConverter[] memory converters) {\n        converters = allConverters;\n    }\n\n    /// @notice This function checks if the given address is a converter or not\n    /// @param _tokenConverter Address of the token converter\n    /// @return isConverter true if given address is converter otherwise false\n    function isTokenConverter(address _tokenConverter) external view returns (bool isConverter) {\n        uint128 index = _findConverterIndex(IAbstractTokenConverter(_tokenConverter));\n\n        if (index != type(uint128).max) {\n            isConverter = true;\n        }\n    }\n\n    /// @notice Adds new converter contract to the array\n    /// @param _tokenConverter Address of the token converter\n    /// @custom:error ConverterAlreadyExists is thrown when new tokenconverter to add already exists\n    /// @custom:event ConverterAdded is emitted on success\n    function _addTokenConverter(IAbstractTokenConverter _tokenConverter) internal {\n        if (\n            (address(_tokenConverter) == address(0)) || (address(_tokenConverter.converterNetwork()) != address(this))\n        ) {\n            revert InvalidTokenConverterAddress();\n        }\n\n        uint128 index = _findConverterIndex(_tokenConverter);\n        if (index != type(uint128).max) revert ConverterAlreadyExists();\n\n        allConverters.push(_tokenConverter);\n        _ensureMaxLoops(allConverters.length);\n\n        emit ConverterAdded(address(_tokenConverter));\n    }\n\n    /// @notice Used to get the array of converters supporting conversions, arranged in descending order based on token balances\n    /// @param _tokenAddressIn Address of tokenIn\n    /// @param _tokenAddressOut Address of tokenOut\n    /// @param forConverters Bool to filter out converters on the basis of the conversionAccess\n    /// @return converters Array of converters\n    /// @return convertersBalance Array of balances with respect to token out\n    function _findTokenConverters(\n        address _tokenAddressIn,\n        address _tokenAddressOut,\n        bool forConverters\n    ) internal returns (address[] memory converters, uint256[] memory convertersBalance) {\n        uint128 convertersLength = uint128(allConverters.length);\n\n        // Create a dynamic array to store the matching converters\n        converters = new address[](convertersLength);\n        convertersBalance = new uint256[](convertersLength);\n        uint128 count;\n\n        for (uint128 i; i < convertersLength; ) {\n            IAbstractTokenConverter converter = allConverters[i];\n\n            unchecked {\n                ++i;\n            }\n\n            if ((address(converter.converterNetwork()) != address(this)) || msg.sender == address(converter)) {\n                continue;\n            }\n\n            (, IAbstractTokenConverter.ConversionAccessibility conversionAccess) = converter.conversionConfigurations(\n                _tokenAddressIn,\n                _tokenAddressOut\n            );\n\n            if (conversionAccess == IAbstractTokenConverter.ConversionAccessibility.ALL) {\n                converters[count] = address(converter);\n                convertersBalance[count] = converter.balanceOf(_tokenAddressOut);\n                ++count;\n            } else if (\n                forConverters &&\n                (conversionAccess == IAbstractTokenConverter.ConversionAccessibility.ONLY_FOR_CONVERTERS)\n            ) {\n                converters[count] = address(converter);\n                convertersBalance[count] = converter.balanceOf(_tokenAddressOut);\n                ++count;\n            } else if (\n                !forConverters && (conversionAccess == IAbstractTokenConverter.ConversionAccessibility.ONLY_FOR_USERS)\n            ) {\n                converters[count] = address(converter);\n                convertersBalance[count] = converter.balanceOf(_tokenAddressOut);\n                ++count;\n            }\n        }\n\n        // Resize the array to the actual number of matching converters\n        assembly {\n            mstore(converters, count)\n            mstore(convertersBalance, count)\n        }\n        sort(convertersBalance, converters);\n    }\n\n    /// @notice Used to get the index of the converter stored in the array\n    /// This will return the index if the converter exists in the array otherwise will return type(uint128).max\n    /// @param _tokenConverter Address of the token converter\n    /// @return index of the converter address in the allConverters array\n    function _findConverterIndex(IAbstractTokenConverter _tokenConverter) internal view returns (uint128 index) {\n        index = type(uint128).max; // Not found, return a large value\n\n        uint128 convertersLength = uint128(allConverters.length);\n        for (uint128 i; i < convertersLength; ) {\n            if (allConverters[i] == _tokenConverter) {\n                index = i;\n            }\n            unchecked {\n                ++i;\n            }\n        }\n    }\n}\n"
      },
      "contracts/TokenConverter/IAbstractTokenConverter.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport { ResilientOracle } from \"@venusprotocol/oracle/contracts/ResilientOracle.sol\";\nimport { IConverterNetwork } from \"../Interfaces/IConverterNetwork.sol\";\n\n/// @notice Interface for AbstractTokenConverter\n/// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion\ninterface IAbstractTokenConverter {\n    /// @notice This enum define the all possible ways of conversion can happen\n    enum ConversionAccessibility {\n        NONE, // Conversion is disable for the pair\n        ALL, // Conversion is enable for private conversion and users\n        ONLY_FOR_CONVERTERS, // Conversion is enable only for private conversion\n        ONLY_FOR_USERS // Conversion is enable only for users\n    }\n\n    /// @notice This struct represents the configuration for a token conversion.\n    struct ConversionConfig {\n        /// incentive on conversion of tokens in mantissa i.e 10% incentive would be 0.1 * 1e18\n        uint256 incentive;\n        /// enable or disable conversion for users or converters or both or none\n        ConversionAccessibility conversionAccess;\n    }\n\n    /// @notice Pause conversion of tokens\n    function pauseConversion() external;\n\n    /// @notice Resume conversion of tokens.\n    function resumeConversion() external;\n\n    /// @notice Sets a new price oracle\n    /// @param priceOracle_ Address of the new price oracle to set\n    function setPriceOracle(ResilientOracle priceOracle_) external;\n\n    /// @notice Set the configuration for new or existing convert pair\n    /// @param tokenAddressIn Address of tokenIn\n    /// @param tokenAddressOut Address of tokenOut\n    /// @param conversionConfig ConversionConfig config details to update\n    function setConversionConfig(\n        address tokenAddressIn,\n        address tokenAddressOut,\n        ConversionConfig calldata conversionConfig\n    ) external;\n\n    /// @notice Convert exact amount of tokenAddressIn for tokenAddressOut\n    /// @dev Method does not support deflationary tokens transfer\n    /// @param amountInMantissa Amount of tokenAddressIn\n    /// @param amountOutMinMantissa Min amount of tokenAddressOut required as output\n    /// @param tokenAddressIn Address of the token to convert\n    /// @param tokenAddressOut Address of the token to get after convert\n    /// @param to Address of the tokenAddressOut receiver\n    function convertExactTokens(\n        uint256 amountInMantissa,\n        uint256 amountOutMinMantissa,\n        address tokenAddressIn,\n        address tokenAddressOut,\n        address to\n    ) external returns (uint256 actualAmountIn, uint256 actualAmountOut);\n\n    /// @notice Convert tokens for tokenAddressIn for exact amount of tokenAddressOut\n    /// @dev Method does not support deflationary tokens transfer\n    /// @param amountInMaxMantissa Max amount of tokenAddressIn\n    /// @param amountOutMantissa Amount of tokenAddressOut required as output\n    /// @param tokenAddressIn Address of the token to convert\n    /// @param tokenAddressOut Address of the token to get after convert\n    /// @param to Address of the tokenAddressOut receiver\n    function convertForExactTokens(\n        uint256 amountInMaxMantissa,\n        uint256 amountOutMantissa,\n        address tokenAddressIn,\n        address tokenAddressOut,\n        address to\n    ) external returns (uint256 actualAmountIn, uint256 actualAmountOut);\n\n    /// @notice Convert exact amount of tokenAddressIn for tokenAddressOut\n    /// @param amountInMantissa Amount of tokenAddressIn\n    /// @param amountOutMinMantissa Min amount of tokenAddressOut required as output\n    /// @param tokenAddressIn Address of the token to convert\n    /// @param tokenAddressOut Address of the token to get after convert\n    /// @param to Address of the tokenAddressOut receiver\n    function convertExactTokensSupportingFeeOnTransferTokens(\n        uint256 amountInMantissa,\n        uint256 amountOutMinMantissa,\n        address tokenAddressIn,\n        address tokenAddressOut,\n        address to\n    ) external returns (uint256 actualAmountIn, uint256 actualAmountOut);\n\n    /// @notice Convert tokens for tokenAddressIn for exact amount of tokenAddressOut\n    /// @param amountInMaxMantissa Max amount of tokenAddressIn\n    /// @param amountOutMantissa Amount of tokenAddressOut required as output\n    /// @param tokenAddressIn Address of the token to convert\n    /// @param tokenAddressOut Address of the token to get after convert\n    /// @param to Address of the tokenAddressOut receiver\n    function convertForExactTokensSupportingFeeOnTransferTokens(\n        uint256 amountInMaxMantissa,\n        uint256 amountOutMantissa,\n        address tokenAddressIn,\n        address tokenAddressOut,\n        address to\n    ) external returns (uint256 actualAmountIn, uint256 actualAmountOut);\n\n    /// @notice Get the configuration for the pair of the tokens\n    /// @param tokenAddressIn Address of the token to convert\n    /// @param tokenAddressOut Address of the token to get after conversion\n    /// @return incentives Percentage of incentives to be distributed for the pair of tokens\n    /// @return conversionAccess Accessibility for the pair of tokens\n    function conversionConfigurations(address tokenAddressIn, address tokenAddressOut)\n        external\n        returns (uint256 incentives, ConversionAccessibility conversionAccess);\n\n    /// @notice Get the address of the converterNetwork\n    function converterNetwork() external returns (IConverterNetwork converterNetwork);\n\n    /// @notice To get the amount of tokenAddressOut tokens sender could receive on providing amountInMantissa tokens of tokenAddressIn\n    /// @param amountInMantissa Amount of tokenAddressIn\n    /// @param tokenAddressIn Address of the token to convert\n    /// @param tokenAddressOut Address of the token to get after conversion\n    /// @return amountConvertedMantissa Amount of tokenAddressIn should be transferred after conversion\n    /// @return amountOutMantissa Amount of the tokenAddressOut sender should receive after conversion\n    /// @custom:error InsufficientInputAmount error is thrown when given input amount is zero\n    /// @custom:error ConversionConfigNotEnabled is thrown when conversion is disabled or config does not exist for given pair\n    function getUpdatedAmountOut(\n        uint256 amountInMantissa,\n        address tokenAddressIn,\n        address tokenAddressOut\n    ) external returns (uint256 amountConvertedMantissa, uint256 amountOutMantissa);\n\n    /// @notice To get the amount of tokenAddressIn tokens sender would send on receiving amountOutMantissa tokens of tokenAddressOut\n    /// @param amountOutMantissa Amount of tokenAddressOut user wants to receive\n    /// @param tokenAddressIn Address of the token to convert\n    /// @param tokenAddressOut Address of the token to get after conversion\n    /// @return amountConvertedMantissa Amount of tokenAddressOut should be transferred after conversion\n    /// @return amountInMantissa Amount of the tokenAddressIn sender would send to contract before conversion\n    /// @custom:error InsufficientInputAmount error is thrown when given input amount is zero\n    /// @custom:error ConversionConfigNotEnabled is thrown when conversion is disabled or config does not exist for given pair\n    function getUpdatedAmountIn(\n        uint256 amountOutMantissa,\n        address tokenAddressIn,\n        address tokenAddressOut\n    ) external returns (uint256 amountConvertedMantissa, uint256 amountInMantissa);\n\n    /// @notice To get the amount of tokenAddressIn tokens sender would send on receiving amountOutMantissa tokens of tokenAddressOut\n    /// @dev This function retrieves values without altering token prices.\n    /// @param amountOutMantissa Amount of tokenAddressOut user wants to receive\n    /// @param tokenAddressIn Address of the token to convert\n    /// @param tokenAddressOut Address of the token to get after conversion\n    /// @return amountConvertedMantissa Amount of tokenAddressOut should be transferred after conversion\n    /// @return amountInMantissa Amount of the tokenAddressIn sender would send to contract before conversion\n    /// @custom:error InsufficientInputAmount error is thrown when given input amount is zero\n    /// @custom:error ConversionConfigNotEnabled is thrown when conversion is disabled or config does not exist for given pair\n    function getAmountIn(\n        uint256 amountOutMantissa,\n        address tokenAddressIn,\n        address tokenAddressOut\n    ) external view returns (uint256 amountConvertedMantissa, uint256 amountInMantissa);\n\n    /// @notice To get the amount of tokenAddressOut tokens sender could receive on providing amountInMantissa tokens of tokenAddressIn\n    /// @dev This function retrieves values without altering token prices.\n    /// @param amountInMantissa Amount of tokenAddressIn\n    /// @param tokenAddressIn Address of the token to convert\n    /// @param tokenAddressOut Address of the token to get after conversion\n    /// @return amountConvertedMantissa Amount of tokenAddressIn should be transferred after conversion\n    /// @return amountOutMantissa Amount of the tokenAddressOut sender should receive after conversion\n    /// @custom:error InsufficientInputAmount error is thrown when given input amount is zero\n    /// @custom:error ConversionConfigNotEnabled is thrown when conversion is disabled or config does not exist for given pair\n    function getAmountOut(\n        uint256 amountInMantissa,\n        address tokenAddressIn,\n        address tokenAddressOut\n    ) external view returns (uint256 amountConvertedMantissa, uint256 amountOutMantissa);\n\n    /// @notice Get the balance for specific token\n    /// @param token Address of the token\n    /// @return tokenBalance Balance of the token the contract has\n    function balanceOf(address token) external view returns (uint256 tokenBalance);\n}\n"
      },
      "contracts/Utils/ArrayHelpers.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/// @notice Used to sort addresses array based on their token balances\n/// @param arr Array of token balances of different addresses\n/// @param addrs Array containing these addresses\nfunction sort(uint256[] memory arr, address[] memory addrs) pure {\n    if (arr.length > 1) {\n        return quickSortDescending(arr, addrs, 0, arr.length - 1);\n    }\n}\n\n/// @notice Used to sort addresses array based on their token balances\n/// @param arr Array of token balances of different addresses\n/// @param addrs Array containing these addresses\n/// @param left index of first value\n/// @param right index of last value\nfunction quickSortDescending(\n    uint256[] memory arr,\n    address[] memory addrs,\n    uint256 left,\n    uint256 right\n) pure {\n    if (left >= right) return;\n    uint256 p = arr[(left + right) / 2]; // p = the pivot element\n    uint256 i = left;\n    uint256 j = right;\n    while (i < j) {\n        while (arr[i] > p) ++i;\n        while (arr[j] < p) --j; // arr[j] < p means p still to the right, so j > 0\n        if (arr[i] < arr[j]) {\n            (arr[i], arr[j]) = (arr[j], arr[i]);\n            (addrs[i], addrs[j]) = (addrs[j], addrs[i]);\n        } else {\n            ++i;\n        }\n    }\n\n    if (j > left) quickSortDescending(arr, addrs, left, j - 1); // j > left, so j > 0\n    quickSortDescending(arr, addrs, j + 1, right);\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 10000
      },
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "metadata": {
        "useLiteralContent": true
      },
      "libraries": {}
    }
  }}