File size: 61,720 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
  "language": "Solidity",
  "sources": {
    "contracts/handlers/GenericHandlerUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../interfaces/IGenericHandler.sol\";\nimport \"../interfaces/iRouterCrossTalk.sol\";\nimport \"../interfaces/iGBridge.sol\";\nimport \"../interfaces/IFeeManagerGeneric.sol\";\n\n/// @title Handles generic deposits and deposit executions.\n/// @author Router Protocol\n/// @notice This contract is intended to be used with the Bridge contract.\ncontract GenericHandlerUpgradeable is Initializable, AccessControlUpgradeable {\n    using AddressUpgradeable for address;\n    using SafeERC20Upgradeable for IERC20Upgradeable;\n    // ----------------------------------------------------------------- //\n    //                        DS Section Starts                          //\n    // ----------------------------------------------------------------- //\n\n    bytes32 public constant BRIDGE_ROLE = keccak256(\"BRIDGE_ROLE\");\n\n    bytes32 public constant FEE_SETTER_ROLE = keccak256(\"FEE_SETTER_ROLE\");\n\n    iGBridge public bridge;\n\n    iFeeManagerGeneric private feeManager;\n\n    bytes32 private resourceID;\n\n    mapping(uint8 => mapping(uint64 => DepositRecord)) private _depositRecords;\n\n    mapping(uint8 => mapping(uint64 => ExecuteRecord)) private _executeRecords;\n\n    struct ExecuteRecord {\n        bool isExecuted;\n        bool _status;\n        bytes _callback;\n    }\n\n    struct DepositRecord {\n        bytes32 _resourceID;\n        uint8 _srcChainID;\n        uint8 _destChainID;\n        uint64 _nonce;\n        address _srcAddress;\n        address _destAddress;\n        bytes4 _selector;\n        bytes data;\n        bytes32 hash;\n        uint256 _gas;\n        address _feeToken;\n    }\n\n    struct RouterLinker {\n        address _rSyncContract;\n        uint8 _chainID;\n        address _linkedContract;\n    }\n\n    mapping(uint8 => uint256) private defaultGas;\n    mapping(uint8 => uint256) private defaultGasPrice;\n    mapping(uint8 => mapping(uint64 => FeeRecord)) private _feeRecord;\n\n    struct FeeRecord {\n        uint8 _destChainID;\n        uint64 _nonce;\n        address _feeToken;\n        uint256 _gasLimit;\n        uint256 _gasPrice;\n        uint256 _feeAmount;\n    }\n\n    uint8 private _chainId;\n\n    event ReplayEvent(\n        uint8 indexed destinationChainID,\n        bytes32 indexed resourceID,\n        uint64 indexed depositNonce,\n        uint256 widgetID\n    );\n\n    // ----------------------------------------------------------------- //\n    //                        DS Section Ends                            //\n    // ----------------------------------------------------------------- //\n\n    // ----------------------------------------------------------------- //\n    //                        Init Section Starts                        //\n    // ----------------------------------------------------------------- //\n\n    function __GenericHandlerUpgradeable_init(address _bridge, bytes32 _resourceID) internal initializer {\n        __AccessControl_init();\n\n        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n        _setupRole(BRIDGE_ROLE, _bridge);\n        _setupRole(FEE_SETTER_ROLE, msg.sender);\n\n        bridge = iGBridge(_bridge);\n        resourceID = _resourceID;\n    }\n\n    function __GenericHandlerUpgradeable_init_unchained() internal initializer {}\n\n    function initialize(address _bridge, bytes32 _resourceID) external initializer {\n        __GenericHandlerUpgradeable_init(_bridge, _resourceID);\n    }\n\n    // ----------------------------------------------------------------- //\n    //                        Init Section Ends                          //\n    // ----------------------------------------------------------------- //\n\n    // ----------------------------------------------------------------- //\n    //                        Mapping Section Starts                     //\n    // ----------------------------------------------------------------- //\n\n    /// @notice Function Maps the two contracts on cross chain enviroment\n    /// @param linker Linker object to be verified\n    function MapContract(RouterLinker calldata linker) external {\n        iRouterCrossTalk crossTalk = iRouterCrossTalk(linker._rSyncContract);\n        require(\n            msg.sender == crossTalk.fetchLinkSetter(),\n            \"Router Generichandler : Only Link Setter can map contracts\"\n        );\n        crossTalk.Link{ gas: 57786 }(linker._chainID, linker._linkedContract);\n    }\n\n    /// @notice Function UnMaps the two contracts on cross chain enviroment\n    /// @param linker Linker object to be verified\n\n    function UnMapContract(RouterLinker calldata linker) external {\n        iRouterCrossTalk crossTalk = iRouterCrossTalk(linker._rSyncContract);\n        require(\n            msg.sender == crossTalk.fetchLinkSetter(),\n            \"Router Generichandler : Only Link Setter can unmap contracts\"\n        );\n        crossTalk.Unlink{ gas: 35035 }(linker._chainID);\n    }\n\n    // ----------------------------------------------------------------- //\n    //                        Mapping Section Ends                       //\n    // ----------------------------------------------------------------- //\n\n    // ----------------------------------------------------------------- //\n    //                        Deposit Section Starts                     //\n    // ----------------------------------------------------------------- //\n\n    /// @notice Function fired to fetch chain ID from bridge\n    /// @return chainId for this chain\n    function fetch_chainID() external view returns (uint8) {\n        return _chainId;\n    }\n\n    /// @notice Function fired to trigger Cross Chain Communication\n    /// @param  _destChainID Destination ChainID\n    /// @param  _data Data for the cross chain function.\n    /// @param  _gasLimit Gas Limit allowed for the transaction.\n    /// @param  _gasPrice Gas Price for the transaction.\n    /// @param  _feeToken Fee Token for the transaction.\n    function genericDeposit(\n        uint8 _destChainID,\n        bytes calldata _data,\n        uint256 _gasLimit,\n        uint256 _gasPrice,\n        address _feeToken\n    ) external returns (uint64) {\n        require(defaultGas[_destChainID] != 0, \"Router Generichandler : Destination Gas Not Set\");\n        require(defaultGasPrice[_destChainID] != 0, \"Router Generichandler : Destination Gas Price Not Set\");\n\n        uint64 _nonce = bridge.genericDeposit(_destChainID, resourceID);\n        iRouterCrossTalk crossTalk = iRouterCrossTalk(msg.sender);\n        address destAddress = crossTalk.fetchLink(_destChainID);\n\n        uint256 gasLimit = _gasLimit < defaultGas[_destChainID] ? defaultGas[_destChainID] : _gasLimit;\n        uint256 gasPrice = _gasPrice < defaultGasPrice[_destChainID] ? defaultGasPrice[_destChainID] : _gasPrice;\n\n        bytes4 _selector = abi.decode(_data, (bytes4));\n\n        _genericDeposit(_nonce, _destChainID, _selector, _data, gasLimit, gasPrice, _feeToken, destAddress);\n        return _nonce;\n    }\n\n    /// @notice Function fired to trigger Cross Chain Communication.\n    /// @param  _nonce Nonce for the deposit.\n    /// @param  _destChainID Destination ChainID.\n    /// @param  _selector Selector for the cross chain function.\n    /// @param  _data Data for the cross chain function.\n    /// @param  _gasLimit Gas Limit allowed for the transaction.\n    /// @param  _gasPrice Gas Price for the transaction.\n    /// @param  _feeToken Fee Token for the transaction.\n    /// @param  _destAddress Address of crosstalk on destination chain.\n    function _genericDeposit(\n        uint64 _nonce,\n        uint8 _destChainID,\n        bytes4 _selector,\n        bytes calldata _data,\n        uint256 _gasLimit,\n        uint256 _gasPrice,\n        address _feeToken,\n        address _destAddress\n    ) internal {\n        uint256 fees = deductFee(_destChainID, _feeToken, _gasLimit, _gasPrice, false);\n        bytes32 hash = keccak256(abi.encode(_destChainID, _nonce));\n\n        _depositRecords[_destChainID][_nonce] = DepositRecord(\n            resourceID,\n            _chainId,\n            _destChainID,\n            _nonce,\n            msg.sender,\n            _destAddress,\n            _selector,\n            _data,\n            hash,\n            _gasLimit,\n            _feeToken\n        );\n\n        _feeRecord[_destChainID][_nonce] = FeeRecord(_destChainID, _nonce, _feeToken, _gasLimit, _gasPrice, fees);\n    }\n\n    /// @notice Function to replay a transaction which was stuck due to underpricing of gas\n    /// @param  _destChainID Destination ChainID\n    /// @param  _depositNonce Nonce for the transaction.\n    /// @param  _gasLimit Gas limit allowed for the transaction.\n    /// @param  _gasPrice Gas Price for the transaction.\n    function replayGenericDeposit(\n        uint8 _destChainID,\n        uint64 _depositNonce,\n        uint256 _gasLimit,\n        uint256 _gasPrice\n    ) external {\n        require(defaultGas[_destChainID] != 0, \"Router Generichandler : Destination Gas Not Set\");\n        require(defaultGasPrice[_destChainID] != 0, \"Router Generichandler : Destination Gas Price Not Set\");\n\n        DepositRecord storage record = _depositRecords[_destChainID][_depositNonce];\n        require(record._feeToken != address(0), \"GenericHandler: Record not found\");\n        require(record._srcAddress == msg.sender, \"GenericHandler: Unauthorized transaction\");\n\n        uint256 gasLimit = _gasLimit < defaultGas[_destChainID] ? defaultGas[_destChainID] : _gasLimit;\n        uint256 gasPrice = _gasPrice < defaultGasPrice[_destChainID] ? defaultGasPrice[_destChainID] : _gasPrice;\n\n        uint256 fee = deductFee(_destChainID, record._feeToken, gasLimit, gasPrice, true);\n\n        _feeRecord[_destChainID][_depositNonce]._gasLimit = gasLimit;\n        _feeRecord[_destChainID][_depositNonce]._gasPrice = gasPrice;\n        _feeRecord[_destChainID][_depositNonce]._feeAmount += fee;\n\n        emit ReplayEvent(_destChainID, resourceID, record._nonce, 0);\n    }\n\n    /// @notice Function fetches deposit record\n    /// @param  _ChainID CHainID of the deposit\n    /// @param  _nonce Nonce of the deposit\n    /// @return DepositRecord\n    function fetchDepositRecord(uint8 _ChainID, uint64 _nonce) external view returns (DepositRecord memory) {\n        return _depositRecords[_ChainID][_nonce];\n    }\n\n    /// @notice Function fetches fee record\n    /// @param  _ChainID Destination ChainID of the deposit\n    /// @param  _nonce Nonce of the deposit\n    /// @return feeRecord\n    function fetchFeeRecord(uint8 _ChainID, uint64 _nonce) external view returns (FeeRecord memory) {\n        return _feeRecord[_ChainID][_nonce];\n    }\n\n    /// @notice Function fetches execute record\n    /// @param  _ChainID CHainID of the deposit\n    /// @param  _nonce Nonce of the deposit\n    /// @return ExecuteRecord\n    function fetchExecuteRecord(uint8 _ChainID, uint64 _nonce) external view returns (ExecuteRecord memory) {\n        return _executeRecords[_ChainID][_nonce];\n    }\n\n    /// @notice Function fetches resourceId\n    function fetchResourceID() external view returns (bytes32) {\n        return resourceID;\n    }\n\n    // ----------------------------------------------------------------- //\n    //                        Deposit Section Ends                       //\n    // ----------------------------------------------------------------- //\n\n    // ----------------------------------------------------------------- //\n    //                        Execute Section Starts                     //\n    // ----------------------------------------------------------------- //\n\n    /// @notice Function Executes a cross Chain Request on destination chain and can only be triggered by bridge\n    /// @dev Can only be called by the bridge\n    /// @param  _data Cross chain Data recived from relayer\n    /// @return true\n    function executeProposal(bytes calldata _data) external onlyRole(BRIDGE_ROLE) returns (bool) {\n        DepositRecord memory depositData = decodeData(_data);\n        require(\n            _executeRecords[depositData._srcChainID][depositData._nonce].isExecuted == false,\n            \"GenericHandler: Already executed\"\n        );\n        if (!depositData._destAddress.isContract()) {\n            _executeRecords[depositData._srcChainID][depositData._nonce]._callback = \"\";\n            _executeRecords[depositData._srcChainID][depositData._nonce]._status = false;\n            _executeRecords[depositData._srcChainID][depositData._nonce].isExecuted = true;\n            return true;\n        }\n        (bool success, bytes memory callback) = depositData._destAddress.call(\n            abi.encodeWithSelector(\n                0x06d07c59, // routerSync(uint8,address,bytes)\n                depositData._srcChainID,\n                depositData._srcAddress,\n                depositData.data\n            )\n        );\n        _executeRecords[depositData._srcChainID][depositData._nonce]._callback = callback;\n        _executeRecords[depositData._srcChainID][depositData._nonce]._status = success;\n        _executeRecords[depositData._srcChainID][depositData._nonce].isExecuted = true;\n        return true;\n    }\n\n    /// @notice Function Decodes the data element recived from bridge\n    /// @param  _data Cross chain Data recived from relayer\n    /// @return DepositRecord\n    function decodeData(bytes calldata _data) internal pure returns (DepositRecord memory) {\n        DepositRecord memory depositData;\n        (\n            depositData._srcChainID,\n            depositData._nonce,\n            depositData._srcAddress,\n            depositData._destAddress,\n            depositData.data\n        ) = abi.decode(_data, (uint8, uint64, address, address, bytes));\n\n        return depositData;\n    }\n\n    // ----------------------------------------------------------------- //\n    //                        Execute Section Ends                       //\n    // ----------------------------------------------------------------- //\n\n    // ----------------------------------------------------------------- //\n    //                    Fee Manager Section Starts                     //\n    // ----------------------------------------------------------------- //\n\n    /// @notice Function fetches fee manager address\n    /// @return feeManager\n    function fetchFeeManager() external view returns (address) {\n        return address(feeManager);\n    }\n\n    /// @notice Function sets fee manager address\n    /// @dev can only be called by default admin address\n    /// @param  _feeManager Address of the fee manager.\n    function setFeeManager(address _feeManager) public onlyRole(DEFAULT_ADMIN_ROLE) {\n        feeManager = iFeeManagerGeneric(_feeManager);\n    }\n\n    /**\n        @notice Function Fetches the default Gas for a chain ID .\n    **/\n    function fetchDefaultGas(uint8 _chainID) external view returns (uint256) {\n        return defaultGas[_chainID];\n    }\n\n    /**\n        @notice Function Sets default gas fees for chain.\n        @param _chainID ChainID of the .\n        @param _defaultGas Default gas for a chainid.\n    **/\n    function setDefaultGas(uint8 _chainID, uint256 _defaultGas) public onlyRole(DEFAULT_ADMIN_ROLE) {\n        defaultGas[_chainID] = _defaultGas;\n    }\n\n    /**\n        @notice Function Fetches the default Gas Price for a chain ID .\n    **/\n    function fetchDefaultGasPrice(uint8 _chainID) external view returns (uint256) {\n        return defaultGasPrice[_chainID];\n    }\n\n    /**\n        @notice Function Sets default gas price for chain.\n        @param _chainID ChainID of the .\n        @param _defaultGasPrice Default gas for a chainid.\n    **/\n    function setDefaultGasPrice(uint8 _chainID, uint256 _defaultGasPrice) public onlyRole(DEFAULT_ADMIN_ROLE) {\n        defaultGasPrice[_chainID] = _defaultGasPrice;\n    }\n\n    /**\n        @notice Function Sets chainId for chain.\n        @param chainId ChainID of the .\n    **/\n    function setChainId(uint8 chainId) public onlyRole(DEFAULT_ADMIN_ROLE) {\n        _chainId = chainId;\n    }\n\n    /// @notice Function Sets the fee for a fee token on to feemanager\n    /// @dev Can only be called by fee setter.\n    /// @param destinationChainID ID of the destination chain.\n    /// @param feeTokenAddress Address of fee token.\n    /// @param feeFactor FeeFactor for the cross chain call.\n    /// @param bridgeFee Base Fee for bridge.\n    /// @param accepted Bool value for enabling and disabling feetoken.\n    function setFees(\n        uint8 destinationChainID,\n        address feeTokenAddress,\n        uint256 feeFactor,\n        uint256 bridgeFee,\n        bool accepted\n    ) external onlyRole(FEE_SETTER_ROLE) {\n        feeManager.setFee(destinationChainID, feeTokenAddress, feeFactor, bridgeFee, accepted);\n    }\n\n    /// @notice Calculates fees for a cross chain Call.\n    /// @param destinationChainID id of the destination chain.\n    /// @param feeTokenAddress Address fee token.\n    /// @param gasLimit Gas limit required for cross chain call.\n    /// @param gasPrice Gas Price for the transaction.\n    /// @return total fees\n    function calculateFees(\n        uint8 destinationChainID,\n        address feeTokenAddress,\n        uint256 gasLimit,\n        uint256 gasPrice\n    ) external view returns (uint256) {\n        require(defaultGas[destinationChainID] != 0, \"GenericHandler : Destination Gas Not Set\");\n        require(defaultGasPrice[destinationChainID] != 0, \"GenericHandler : Destination Gas Price Not Set\");\n\n        uint8 feeTokenDecimals = IERC20MetadataUpgradeable(feeTokenAddress).decimals();\n        uint256 _gasLimit = gasLimit < defaultGas[destinationChainID] ? defaultGas[destinationChainID] : gasLimit;\n        uint256 _gasPrice = gasPrice < defaultGasPrice[destinationChainID]\n            ? defaultGasPrice[destinationChainID]\n            : gasPrice;\n\n        (uint256 feeFactorX10e6, uint256 bridgeFees) = feeManager.getFee(destinationChainID, feeTokenAddress);\n\n        if (feeTokenDecimals < 18) {\n            uint8 decimalsToDivide = 18 - feeTokenDecimals;\n            return bridgeFees + (feeFactorX10e6 * _gasPrice * _gasLimit) / (10**(decimalsToDivide + 6));\n        }\n\n        return (feeFactorX10e6 * _gasLimit * _gasPrice)/(10**6) + bridgeFees;\n    }\n\n    /// @notice Function deducts fees for a cross chain Call.\n    /// @param destinationChainID id of the destination chain.\n    /// @param feeTokenAddress Address fee token.\n    /// @param gasLimit Gas limit required for cross chain call.\n    /// @param gasPrice Gas Price for the transaction.\n    /// @param isReplay True if it is a replay tx.\n    /// @return totalFees\n    function deductFee(\n        uint8 destinationChainID,\n        address feeTokenAddress,\n        uint256 gasLimit,\n        uint256 gasPrice,\n        bool isReplay\n    ) internal returns (uint256) {\n        uint8 feeTokenDecimals = IERC20MetadataUpgradeable(feeTokenAddress).decimals();\n\n        (uint256 feeFactorX10e6, uint256 bridgeFees) = feeManager.getFee(destinationChainID, feeTokenAddress);\n\n        if (isReplay) {\n            bridgeFees = 0;\n        }\n\n        IERC20Upgradeable token = IERC20Upgradeable(feeTokenAddress);\n        uint256 fees;\n\n        if (feeTokenDecimals < 18) {\n            uint8 decimalsToDivide = 18 - feeTokenDecimals;\n            fees = bridgeFees + (feeFactorX10e6 * gasPrice * gasLimit) / (10**(decimalsToDivide + 6));\n        } else {\n            fees = (feeFactorX10e6 * gasLimit * gasPrice)/(10**6) + bridgeFees;\n        }\n\n        token.safeTransferFrom(msg.sender, address(feeManager), fees);\n        return fees;\n    }\n\n    /// @notice Used to manually release ERC20 tokens from FeeManager.\n    /// @dev Can only be called by default admin\n    /// @param tokenAddress Address of token contract to release.\n    /// @param recipient Address to release tokens to.\n    /// @param amount The amount of ERC20 tokens to release.\n    function withdrawFees(\n        address tokenAddress,\n        address recipient,\n        uint256 amount\n    ) external virtual onlyRole(DEFAULT_ADMIN_ROLE) {\n        feeManager.withdrawFee(tokenAddress, recipient, amount);\n    }\n\n    /// @notice Function to set the bridge address\n    /// @dev Can only be called by default admin\n    /// @param _bridge Address of the bridge\n    function setBridge(address _bridge) external onlyRole(DEFAULT_ADMIN_ROLE) {\n        bridge = iGBridge(_bridge);\n    }\n\n    // ----------------------------------------------------------------- //\n    //                    Fee Manager Section Ends                       //\n    // ----------------------------------------------------------------- //\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\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 a proxied contract can't have 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 * 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 initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     */\n    bool 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 Modifier to protect an initializer function from being invoked twice.\n     */\n    modifier initializer() {\n        // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n        // contract may have been reentered.\n        require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n        bool isTopLevelCall = !_initializing;\n        if (isTopLevelCall) {\n            _initializing = true;\n            _initialized = true;\n        }\n\n        _;\n\n        if (isTopLevelCall) {\n            _initializing = false;\n        }\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} modifier, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    function _isConstructor() private view returns (bool) {\n        return !AddressUpgradeable.isContract(address(this));\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        assembly {\n            size := extcodesize(account)\n        }\n        return size > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlUpgradeable.sol\";\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../utils/StringsUpgradeable.sol\";\nimport \"../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n *     require(hasRole(MY_ROLE, msg.sender));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\n    function __AccessControl_init() internal onlyInitializing {\n        __Context_init_unchained();\n        __ERC165_init_unchained();\n        __AccessControl_init_unchained();\n    }\n\n    function __AccessControl_init_unchained() internal onlyInitializing {\n    }\n    struct RoleData {\n        mapping(address => bool) members;\n        bytes32 adminRole;\n    }\n\n    mapping(bytes32 => RoleData) private _roles;\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with a standardized message including the required role.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     *\n     * _Available since v4.1._\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role, _msgSender());\n        _;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view override returns (bool) {\n        return _roles[role].members[account];\n    }\n\n    /**\n     * @dev Revert with a standard message if `account` is missing `role`.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     */\n    function _checkRole(bytes32 role, address account) internal view {\n        if (!hasRole(role, account)) {\n            revert(\n                string(\n                    abi.encodePacked(\n                        \"AccessControl: account \",\n                        StringsUpgradeable.toHexString(uint160(account), 20),\n                        \" is missing role \",\n                        StringsUpgradeable.toHexString(uint256(role), 32)\n                    )\n                )\n            );\n        }\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {\n        return _roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) public virtual override {\n        require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event. Note that unlike {grantRole}, this function doesn't perform any\n     * checks on the calling account.\n     *\n     * [WARNING]\n     * ====\n     * This function should only be called from the constructor when setting\n     * up the initial roles for the system.\n     *\n     * Using this function in any other way is effectively circumventing the admin\n     * system imposed by {AccessControl}.\n     * ====\n     *\n     * NOTE: This function is deprecated in favor of {_grantRole}.\n     */\n    function _setupRole(bytes32 role, address account) internal virtual {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        bytes32 previousAdminRole = getRoleAdmin(role);\n        _roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * Internal function without access restriction.\n     */\n    function _grantRole(bytes32 role, address account) internal virtual {\n        if (!hasRole(role, account)) {\n            _roles[role].members[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * Internal function without access restriction.\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual {\n        if (hasRole(role, account)) {\n            _roles[role].members[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n    uint256[49] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20Upgradeable.sol\";\n"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n    using AddressUpgradeable for address;\n\n    function safeTransfer(\n        IERC20Upgradeable token,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(\n        IERC20Upgradeable token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(\n        IERC20Upgradeable token,\n        address spender,\n        uint256 value\n    ) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(\n        IERC20Upgradeable token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(\n        IERC20Upgradeable token,\n        address spender,\n        uint256 value\n    ) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            uint256 newAllowance = oldAllowance - value;\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) {\n            // Return data is optional\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.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 \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
    },
    "contracts/interfaces/IGenericHandler.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.2;\n\n/// @title Interface for handler that handles generic deposits and deposit executions.\n/// @author Router Protocol.\ninterface IGenericHandler {\n    function genericDeposit(\n        uint8 _destChainID,\n        bytes4 _selector,\n        bytes calldata _data,\n        uint256 _gasLimit,\n        uint256 _gasPrice,\n        address _feeToken\n    ) external returns (uint64);\n\n    function executeProposal(bytes calldata data) external;\n\n    /// @notice Function to replay a transaction which was stuck due to underpricing of gas\n    /// @param  _destChainID Destination ChainID\n    /// @param  _depositNonce Nonce for the transaction.\n    /// @param  _gasLimit Gas limit allowed for the transaction.\n    /// @param  _gasPrice Gas Price for the transaction.\n    function replayGenericDeposit(\n        uint8 _destChainID,\n        uint64 _depositNonce,\n        uint256 _gasLimit,\n        uint256 _gasPrice\n    ) external;\n}\n"
    },
    "contracts/interfaces/iRouterCrossTalk.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface iRouterCrossTalk {\n\n    event Linkevent( uint8 indexed ChainID , address indexed linkedContract );\n\n    event Unlinkevent( uint8 indexed ChainID , address indexed linkedContract );\n\n    event CrossTalkSend(uint8 indexed sourceChain , uint8 indexed destChain , address sourceAddress , address destinationAddress ,bytes4 indexed _interface, bytes _data , bytes32 _hash );\n\n    event CrossTalkReceive(uint8 indexed sourceChain , uint8 indexed destChain , address sourceAddress , address destinationAddress ,bytes4 indexed _interface, bytes _data , bytes32 _hash );\n\n    function routerSync(uint8 srcChainID , address srcAddress , bytes4 _interface , bytes calldata _data , bytes32 hash ) external returns ( bool , bytes memory );\n\n    function Link(uint8 _chainID , address _linkedContract) external;\n\n    function Unlink(uint8 _chainID ) external;\n\n    function fetchLinkSetter( ) external view returns( address);\n\n    function fetchLink( uint8 _chainID ) external view returns( address);\n\n    function fetchBridge( ) external view returns ( address );\n\n    function fetchHandler( ) external view returns ( address );\n\n}\n"
    },
    "contracts/interfaces/iGBridge.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.2;\n\ninterface iGBridge{\n\n    function genericDeposit( uint8 _destChainID, bytes32 _resourceID ) external returns ( uint64 );\n\n    function fetch_chainID( ) external view returns ( uint8 );\n\n}\n"
    },
    "contracts/interfaces/IFeeManagerGeneric.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.2;\n\ninterface iFeeManagerGeneric {\n\n    function withdrawFee(address tokenAddress, address recipient, uint256 amount) external;\n\n    function setFee(\n        uint8 destinationChainID,\n        address feeTokenAddress,\n        uint256 feeFactor,\n        uint256 bridgeFee,\n        bool accepted\n    ) external;\n\n    function getFee(uint8 destinationChainID, address feeTokenAddress) external view returns (uint256 , uint256);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.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 IAccessControlUpgradeable {\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"
    },
    "@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        __Context_init_unchained();\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    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n    bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        // Inspired by OraclizeAPI's implementation - MIT licence\n        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n        if (value == 0) {\n            return \"0\";\n        }\n        uint256 temp = value;\n        uint256 digits;\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n        bytes memory buffer = new bytes(digits);\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return \"0x00\";\n        }\n        uint256 temp = value;\n        uint256 length = 0;\n        while (temp != 0) {\n            length++;\n            temp >>= 8;\n        }\n        return toHexString(value, length);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _HEX_SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n    function __ERC165_init() internal onlyInitializing {\n        __ERC165_init_unchained();\n    }\n\n    function __ERC165_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165Upgradeable).interfaceId;\n    }\n    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n    /**\n     * @dev 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 `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, 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 `sender` to `recipient` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) external returns (bool);\n\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"
    }
  },
  "settings": {
    "evmVersion": "berlin",
    "metadata": {
      "bytecodeHash": "none",
      "useLiteralContent": true
    },
    "optimizer": {
      "enabled": true,
      "runs": 50
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "libraries": {}
  }
}