-
Notifications
You must be signed in to change notification settings - Fork 33
/
bridgeconfig.contractinfo.json
1 lines (1 loc) · 432 KB
/
bridgeconfig.contractinfo.json
1
{"/solidity/BridgeConfigV3_flat.sol:AccessControl":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\n\n\n\n\n\n\n\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping (bytes32 =\u003e uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) { // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n require(set._values.length \u003e index, \"EnumerableSet: index out of bounds\");\n return set._values[index];\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n}\n\n\n\n\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\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 // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size \u003e 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 \u003e= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\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(address target, bytes memory data, string memory errorMessage) 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(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\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(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\n\n\n\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\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 AccessControl is Context {\n using EnumerableSet for EnumerableSet.AddressSet;\n using Address for address;\n\n struct RoleData {\n EnumerableSet.AddressSet members;\n bytes32 adminRole;\n }\n\n mapping (bytes32 =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\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 {_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) public view returns (bool) {\n return _roles[role].members.contains(account);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n return _roles[role].members.length();\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n return _roles[role].members.at(index);\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 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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\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 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) public virtual {\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 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 emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\n _roles[role].adminRole = adminRole;\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (_roles[role].members.add(account)) {\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (_roles[role].members.remove(account)) {\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n\n\n\n\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c \u003c a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b \u003e a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c \u003e= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003c= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003c= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a % b;\n }\n}\n\n\n/**\n * @title BridgeConfig contract\n * @notice This token is used for configuring different tokens on the bridge and mapping them across chains.\n **/\n\ncontract BridgeConfigV3 is AccessControl {\n using SafeMath for uint256;\n bytes32 public constant BRIDGEMANAGER_ROLE = keccak256(\"BRIDGEMANAGER_ROLE\");\n bytes32[] private _allTokenIDs;\n mapping(bytes32 =\u003e Token[]) private _allTokens; // key is tokenID\n mapping(uint256 =\u003e mapping(string =\u003e bytes32)) private _tokenIDMap; // key is chainID,tokenAddress\n mapping(bytes32 =\u003e mapping(uint256 =\u003e Token)) private _tokens; // key is tokenID,chainID\n mapping(address =\u003e mapping(uint256 =\u003e Pool)) private _pool; // key is tokenAddress,chainID\n mapping(uint256 =\u003e uint256) private _maxGasPrice; // key is tokenID,chainID\n uint256 public constant bridgeConfigVersion = 3;\n\n // the denominator used to calculate fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // this struct must be initialized using setTokenConfig for each token that directly interacts with the bridge\n struct Token {\n uint256 chainId;\n string tokenAddress;\n uint8 tokenDecimals;\n uint256 maxSwap;\n uint256 minSwap;\n uint256 swapFee;\n uint256 maxSwapFee;\n uint256 minSwapFee;\n bool hasUnderlying;\n bool isUnderlying;\n }\n\n struct Pool {\n address tokenAddress;\n uint256 chainId;\n address poolAddress;\n bool metaswap;\n }\n\n constructor() public {\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n }\n\n /**\n * @notice Returns a list of all existing token IDs converted to strings\n */\n function getAllTokenIDs() public view returns (string[] memory result) {\n uint256 length = _allTokenIDs.length;\n result = new string[](length);\n for (uint256 i = 0; i \u003c length; ++i) {\n result[i] = toString(_allTokenIDs[i]);\n }\n }\n\n function _getTokenID(string memory tokenAddress, uint256 chainID) internal view returns (string memory) {\n return toString(_tokenIDMap[chainID][tokenAddress]);\n }\n\n function getTokenID(string memory tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(tokenAddress), chainID);\n }\n\n /**\n * @notice Returns the token ID (string) of the cross-chain token inputted\n * @param tokenAddress address of token to get ID for\n * @param chainID chainID of which to get token ID for\n */\n function getTokenID(address tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(toString(tokenAddress)), chainID);\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getToken(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getTokenByID(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns token config struct, given an address and chainID\n * @param tokenAddress Matches the token ID by using a combo of address + chain ID\n * @param chainID Chain ID of which token to get config for\n */\n function getTokenByAddress(string memory tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(tokenAddress)]][chainID];\n }\n\n function getTokenByEVMAddress(address tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(toString(tokenAddress))]][chainID];\n }\n\n /**\n * @notice Returns true if the token has an underlying token -- meaning the token is deposited into the bridge\n * @param tokenID String to check if it is a withdraw/underlying token\n */\n function hasUnderlyingToken(string memory tokenID) public view returns (bool) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].hasUnderlying) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Returns which token is the underlying token to withdraw\n * @param tokenID string token ID\n */\n function getUnderlyingToken(string memory tokenID) public view returns (Token memory token) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].isUnderlying) {\n return _mcTokens[i];\n }\n }\n }\n\n /**\n @notice Public function returning if token ID exists given a string\n */\n function isTokenIDExist(string memory tokenID) public view returns (bool) {\n return _isTokenIDExist(toBytes32(tokenID));\n }\n\n /**\n @notice Internal function returning if token ID exists given bytes32 version of the ID\n */\n function _isTokenIDExist(bytes32 tokenID) internal view returns (bool) {\n for (uint256 i = 0; i \u003c _allTokenIDs.length; ++i) {\n if (_allTokenIDs[i] == tokenID) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Internal function which handles logic of setting token ID and dealing with mappings\n * @param tokenID bytes32 version of ID\n * @param chainID which chain to set the token config for\n * @param tokenToAdd Token object to set the mapping to\n */\n function _setTokenConfig(\n bytes32 tokenID,\n uint256 chainID,\n Token memory tokenToAdd\n ) internal returns (bool) {\n _tokens[tokenID][chainID] = tokenToAdd;\n if (!_isTokenIDExist(tokenID)) {\n _allTokenIDs.push(tokenID);\n }\n\n Token[] storage _mcTokens = _allTokens[tokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].chainId == chainID) {\n string memory oldToken = _mcTokens[i].tokenAddress;\n if (!compareStrings(tokenToAdd.tokenAddress, oldToken)) {\n _mcTokens[i].tokenAddress = tokenToAdd.tokenAddress;\n _tokenIDMap[chainID][oldToken] = keccak256(\"\");\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n }\n }\n }\n _mcTokens.push(tokenToAdd);\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n return true;\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n address tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n return\n setTokenConfig(\n tokenID,\n chainID,\n toString(tokenAddress),\n tokenDecimals,\n maxSwap,\n minSwap,\n swapFee,\n maxSwapFee,\n minSwapFee,\n hasUnderlying,\n isUnderlying\n );\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n string memory tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n Token memory tokenToAdd;\n tokenToAdd.tokenAddress = _toLower(tokenAddress);\n tokenToAdd.tokenDecimals = tokenDecimals;\n tokenToAdd.maxSwap = maxSwap;\n tokenToAdd.minSwap = minSwap;\n tokenToAdd.swapFee = swapFee;\n tokenToAdd.maxSwapFee = maxSwapFee;\n tokenToAdd.minSwapFee = minSwapFee;\n tokenToAdd.hasUnderlying = hasUnderlying;\n tokenToAdd.isUnderlying = isUnderlying;\n tokenToAdd.chainId = chainID;\n\n return _setTokenConfig(toBytes32(tokenID), chainID, tokenToAdd);\n }\n\n function _calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) internal view returns (uint256) {\n Token memory token = _tokens[_tokenIDMap[chainID][tokenAddress]][chainID];\n uint256 calculatedSwapFee = amount.mul(token.swapFee).div(FEE_DENOMINATOR);\n if (calculatedSwapFee \u003e token.minSwapFee \u0026\u0026 calculatedSwapFee \u003c token.maxSwapFee) {\n return calculatedSwapFee;\n } else if (calculatedSwapFee \u003e token.maxSwapFee) {\n return token.maxSwapFee;\n } else {\n return token.minSwapFee;\n }\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(tokenAddress), chainID, amount);\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n address tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(toString(tokenAddress)), chainID, amount);\n }\n\n // GAS PRICING\n\n /**\n * @notice sets the max gas price for a chain\n */\n function setMaxGasPrice(uint256 chainID, uint256 maxPrice) public {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n _maxGasPrice[chainID] = maxPrice;\n }\n\n /**\n * @notice gets the max gas price for a chain\n */\n function getMaxGasPrice(uint256 chainID) public view returns (uint256) {\n return _maxGasPrice[chainID];\n }\n\n // POOL CONFIG\n\n function getPoolConfig(address tokenAddress, uint256 chainID) external view returns (Pool memory) {\n return _pool[tokenAddress][chainID];\n }\n\n function setPoolConfig(\n address tokenAddress,\n uint256 chainID,\n address poolAddress,\n bool metaswap\n ) external returns (Pool memory) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender), \"Caller is not Bridge Manager\");\n Pool memory newPool = Pool(tokenAddress, chainID, poolAddress, metaswap);\n _pool[tokenAddress][chainID] = newPool;\n return newPool;\n }\n\n // UTILITY FUNCTIONS\n\n function toString(bytes32 data) internal pure returns (string memory) {\n uint8 i = 0;\n while (i \u003c 32 \u0026\u0026 data[i] != 0) {\n ++i;\n }\n bytes memory bs = new bytes(i);\n for (uint8 j = 0; j \u003c i; ++j) {\n bs[j] = data[j];\n }\n return string(bs);\n }\n\n // toBytes32 converts a string to a bytes 32\n function toBytes32(string memory str) internal pure returns (bytes32 result) {\n require(bytes(str).length \u003c= 32);\n assembly {\n result := mload(add(str, 32))\n }\n }\n\n function toString(address x) internal pure returns (string memory) {\n bytes memory s = new bytes(40);\n for (uint256 i = 0; i \u003c 20; i++) {\n bytes1 b = bytes1(uint8(uint256(uint160(x)) / (2**(8 * (19 - i)))));\n bytes1 hi = bytes1(uint8(b) / 16);\n bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));\n s[2 * i] = char(hi);\n s[2 * i + 1] = char(lo);\n }\n\n string memory addrPrefix = \"0x\";\n\n return concat(addrPrefix, string(s));\n }\n\n function concat(string memory _x, string memory _y) internal pure returns (string memory) {\n bytes memory _xBytes = bytes(_x);\n bytes memory _yBytes = bytes(_y);\n\n string memory _tmpValue = new string(_xBytes.length + _yBytes.length);\n bytes memory _newValue = bytes(_tmpValue);\n\n uint256 i;\n uint256 j;\n\n for (i = 0; i \u003c _xBytes.length; i++) {\n _newValue[j++] = _xBytes[i];\n }\n\n for (i = 0; i \u003c _yBytes.length; i++) {\n _newValue[j++] = _yBytes[i];\n }\n\n return string(_newValue);\n }\n\n function char(bytes1 b) internal pure returns (bytes1 c) {\n if (uint8(b) \u003c 10) {\n c = bytes1(uint8(b) + 0x30);\n } else {\n c = bytes1(uint8(b) + 0x57);\n }\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function _toLower(string memory str) internal pure returns (string memory) {\n bytes memory bStr = bytes(str);\n bytes memory bLower = new bytes(bStr.length);\n for (uint256 i = 0; i \u003c bStr.length; i++) {\n // Uppercase character...\n if ((uint8(bStr[i]) \u003e= 65) \u0026\u0026 (uint8(bStr[i]) \u003c= 90)) {\n // So we add 32 to make it lowercase\n bLower[i] = bytes1(uint8(bStr[i]) + 32);\n } else {\n bLower[i] = bStr[i];\n }\n }\n return string(bLower);\n }\n}\n\n\n\n","language":"Solidity","languageVersion":"0.6.12","compilerVersion":"0.6.12","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Contract module that allows children to implement role-based access control mechanisms. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ``` bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ``` function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it.","events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this. _Available since v3.1._"},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contract module that allows children to implement role-based access control mechanisms. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ``` bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ``` function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it.\",\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this. _Available since v3.1._\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/solidity/BridgeConfigV3_flat.sol\":\"AccessControl\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/solidity/BridgeConfigV3_flat.sol\":{\"keccak256\":\"0xed97c5e2e62a33d867264cf25c64f2215222ad36723fee31796bfd0930a0fffd\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ed38243be38158798b1de0aaa7ba9a22df5f9bca3a1ff9ba814719c9e0391e26\",\"dweb:/ipfs/Qmebz2oFzXzZdE27FNbhhYbvVsDXKPy9pYrBxEVXQDaC4X\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f"}},"/solidity/BridgeConfigV3_flat.sol:Address":{"code":"0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207bff0e2bd493579e1cca2e287bbaf08915fed4ee1fd5bdda0a91d5b8feca389164736f6c634300060c0033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207bff0e2bd493579e1cca2e287bbaf08915fed4ee1fd5bdda0a91d5b8feca389164736f6c634300060c0033","info":{"source":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\n\n\n\n\n\n\n\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping (bytes32 =\u003e uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) { // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n require(set._values.length \u003e index, \"EnumerableSet: index out of bounds\");\n return set._values[index];\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n}\n\n\n\n\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\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 // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size \u003e 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 \u003e= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\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(address target, bytes memory data, string memory errorMessage) 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(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\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(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\n\n\n\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\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 AccessControl is Context {\n using EnumerableSet for EnumerableSet.AddressSet;\n using Address for address;\n\n struct RoleData {\n EnumerableSet.AddressSet members;\n bytes32 adminRole;\n }\n\n mapping (bytes32 =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\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 {_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) public view returns (bool) {\n return _roles[role].members.contains(account);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n return _roles[role].members.length();\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n return _roles[role].members.at(index);\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 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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\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 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) public virtual {\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 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 emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\n _roles[role].adminRole = adminRole;\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (_roles[role].members.add(account)) {\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (_roles[role].members.remove(account)) {\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n\n\n\n\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c \u003c a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b \u003e a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c \u003e= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003c= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003c= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a % b;\n }\n}\n\n\n/**\n * @title BridgeConfig contract\n * @notice This token is used for configuring different tokens on the bridge and mapping them across chains.\n **/\n\ncontract BridgeConfigV3 is AccessControl {\n using SafeMath for uint256;\n bytes32 public constant BRIDGEMANAGER_ROLE = keccak256(\"BRIDGEMANAGER_ROLE\");\n bytes32[] private _allTokenIDs;\n mapping(bytes32 =\u003e Token[]) private _allTokens; // key is tokenID\n mapping(uint256 =\u003e mapping(string =\u003e bytes32)) private _tokenIDMap; // key is chainID,tokenAddress\n mapping(bytes32 =\u003e mapping(uint256 =\u003e Token)) private _tokens; // key is tokenID,chainID\n mapping(address =\u003e mapping(uint256 =\u003e Pool)) private _pool; // key is tokenAddress,chainID\n mapping(uint256 =\u003e uint256) private _maxGasPrice; // key is tokenID,chainID\n uint256 public constant bridgeConfigVersion = 3;\n\n // the denominator used to calculate fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // this struct must be initialized using setTokenConfig for each token that directly interacts with the bridge\n struct Token {\n uint256 chainId;\n string tokenAddress;\n uint8 tokenDecimals;\n uint256 maxSwap;\n uint256 minSwap;\n uint256 swapFee;\n uint256 maxSwapFee;\n uint256 minSwapFee;\n bool hasUnderlying;\n bool isUnderlying;\n }\n\n struct Pool {\n address tokenAddress;\n uint256 chainId;\n address poolAddress;\n bool metaswap;\n }\n\n constructor() public {\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n }\n\n /**\n * @notice Returns a list of all existing token IDs converted to strings\n */\n function getAllTokenIDs() public view returns (string[] memory result) {\n uint256 length = _allTokenIDs.length;\n result = new string[](length);\n for (uint256 i = 0; i \u003c length; ++i) {\n result[i] = toString(_allTokenIDs[i]);\n }\n }\n\n function _getTokenID(string memory tokenAddress, uint256 chainID) internal view returns (string memory) {\n return toString(_tokenIDMap[chainID][tokenAddress]);\n }\n\n function getTokenID(string memory tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(tokenAddress), chainID);\n }\n\n /**\n * @notice Returns the token ID (string) of the cross-chain token inputted\n * @param tokenAddress address of token to get ID for\n * @param chainID chainID of which to get token ID for\n */\n function getTokenID(address tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(toString(tokenAddress)), chainID);\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getToken(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getTokenByID(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns token config struct, given an address and chainID\n * @param tokenAddress Matches the token ID by using a combo of address + chain ID\n * @param chainID Chain ID of which token to get config for\n */\n function getTokenByAddress(string memory tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(tokenAddress)]][chainID];\n }\n\n function getTokenByEVMAddress(address tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(toString(tokenAddress))]][chainID];\n }\n\n /**\n * @notice Returns true if the token has an underlying token -- meaning the token is deposited into the bridge\n * @param tokenID String to check if it is a withdraw/underlying token\n */\n function hasUnderlyingToken(string memory tokenID) public view returns (bool) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].hasUnderlying) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Returns which token is the underlying token to withdraw\n * @param tokenID string token ID\n */\n function getUnderlyingToken(string memory tokenID) public view returns (Token memory token) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].isUnderlying) {\n return _mcTokens[i];\n }\n }\n }\n\n /**\n @notice Public function returning if token ID exists given a string\n */\n function isTokenIDExist(string memory tokenID) public view returns (bool) {\n return _isTokenIDExist(toBytes32(tokenID));\n }\n\n /**\n @notice Internal function returning if token ID exists given bytes32 version of the ID\n */\n function _isTokenIDExist(bytes32 tokenID) internal view returns (bool) {\n for (uint256 i = 0; i \u003c _allTokenIDs.length; ++i) {\n if (_allTokenIDs[i] == tokenID) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Internal function which handles logic of setting token ID and dealing with mappings\n * @param tokenID bytes32 version of ID\n * @param chainID which chain to set the token config for\n * @param tokenToAdd Token object to set the mapping to\n */\n function _setTokenConfig(\n bytes32 tokenID,\n uint256 chainID,\n Token memory tokenToAdd\n ) internal returns (bool) {\n _tokens[tokenID][chainID] = tokenToAdd;\n if (!_isTokenIDExist(tokenID)) {\n _allTokenIDs.push(tokenID);\n }\n\n Token[] storage _mcTokens = _allTokens[tokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].chainId == chainID) {\n string memory oldToken = _mcTokens[i].tokenAddress;\n if (!compareStrings(tokenToAdd.tokenAddress, oldToken)) {\n _mcTokens[i].tokenAddress = tokenToAdd.tokenAddress;\n _tokenIDMap[chainID][oldToken] = keccak256(\"\");\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n }\n }\n }\n _mcTokens.push(tokenToAdd);\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n return true;\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n address tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n return\n setTokenConfig(\n tokenID,\n chainID,\n toString(tokenAddress),\n tokenDecimals,\n maxSwap,\n minSwap,\n swapFee,\n maxSwapFee,\n minSwapFee,\n hasUnderlying,\n isUnderlying\n );\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n string memory tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n Token memory tokenToAdd;\n tokenToAdd.tokenAddress = _toLower(tokenAddress);\n tokenToAdd.tokenDecimals = tokenDecimals;\n tokenToAdd.maxSwap = maxSwap;\n tokenToAdd.minSwap = minSwap;\n tokenToAdd.swapFee = swapFee;\n tokenToAdd.maxSwapFee = maxSwapFee;\n tokenToAdd.minSwapFee = minSwapFee;\n tokenToAdd.hasUnderlying = hasUnderlying;\n tokenToAdd.isUnderlying = isUnderlying;\n tokenToAdd.chainId = chainID;\n\n return _setTokenConfig(toBytes32(tokenID), chainID, tokenToAdd);\n }\n\n function _calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) internal view returns (uint256) {\n Token memory token = _tokens[_tokenIDMap[chainID][tokenAddress]][chainID];\n uint256 calculatedSwapFee = amount.mul(token.swapFee).div(FEE_DENOMINATOR);\n if (calculatedSwapFee \u003e token.minSwapFee \u0026\u0026 calculatedSwapFee \u003c token.maxSwapFee) {\n return calculatedSwapFee;\n } else if (calculatedSwapFee \u003e token.maxSwapFee) {\n return token.maxSwapFee;\n } else {\n return token.minSwapFee;\n }\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(tokenAddress), chainID, amount);\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n address tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(toString(tokenAddress)), chainID, amount);\n }\n\n // GAS PRICING\n\n /**\n * @notice sets the max gas price for a chain\n */\n function setMaxGasPrice(uint256 chainID, uint256 maxPrice) public {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n _maxGasPrice[chainID] = maxPrice;\n }\n\n /**\n * @notice gets the max gas price for a chain\n */\n function getMaxGasPrice(uint256 chainID) public view returns (uint256) {\n return _maxGasPrice[chainID];\n }\n\n // POOL CONFIG\n\n function getPoolConfig(address tokenAddress, uint256 chainID) external view returns (Pool memory) {\n return _pool[tokenAddress][chainID];\n }\n\n function setPoolConfig(\n address tokenAddress,\n uint256 chainID,\n address poolAddress,\n bool metaswap\n ) external returns (Pool memory) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender), \"Caller is not Bridge Manager\");\n Pool memory newPool = Pool(tokenAddress, chainID, poolAddress, metaswap);\n _pool[tokenAddress][chainID] = newPool;\n return newPool;\n }\n\n // UTILITY FUNCTIONS\n\n function toString(bytes32 data) internal pure returns (string memory) {\n uint8 i = 0;\n while (i \u003c 32 \u0026\u0026 data[i] != 0) {\n ++i;\n }\n bytes memory bs = new bytes(i);\n for (uint8 j = 0; j \u003c i; ++j) {\n bs[j] = data[j];\n }\n return string(bs);\n }\n\n // toBytes32 converts a string to a bytes 32\n function toBytes32(string memory str) internal pure returns (bytes32 result) {\n require(bytes(str).length \u003c= 32);\n assembly {\n result := mload(add(str, 32))\n }\n }\n\n function toString(address x) internal pure returns (string memory) {\n bytes memory s = new bytes(40);\n for (uint256 i = 0; i \u003c 20; i++) {\n bytes1 b = bytes1(uint8(uint256(uint160(x)) / (2**(8 * (19 - i)))));\n bytes1 hi = bytes1(uint8(b) / 16);\n bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));\n s[2 * i] = char(hi);\n s[2 * i + 1] = char(lo);\n }\n\n string memory addrPrefix = \"0x\";\n\n return concat(addrPrefix, string(s));\n }\n\n function concat(string memory _x, string memory _y) internal pure returns (string memory) {\n bytes memory _xBytes = bytes(_x);\n bytes memory _yBytes = bytes(_y);\n\n string memory _tmpValue = new string(_xBytes.length + _yBytes.length);\n bytes memory _newValue = bytes(_tmpValue);\n\n uint256 i;\n uint256 j;\n\n for (i = 0; i \u003c _xBytes.length; i++) {\n _newValue[j++] = _xBytes[i];\n }\n\n for (i = 0; i \u003c _yBytes.length; i++) {\n _newValue[j++] = _yBytes[i];\n }\n\n return string(_newValue);\n }\n\n function char(bytes1 b) internal pure returns (bytes1 c) {\n if (uint8(b) \u003c 10) {\n c = bytes1(uint8(b) + 0x30);\n } else {\n c = bytes1(uint8(b) + 0x57);\n }\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function _toLower(string memory str) internal pure returns (string memory) {\n bytes memory bStr = bytes(str);\n bytes memory bLower = new bytes(bStr.length);\n for (uint256 i = 0; i \u003c bStr.length; i++) {\n // Uppercase character...\n if ((uint8(bStr[i]) \u003e= 65) \u0026\u0026 (uint8(bStr[i]) \u003c= 90)) {\n // So we add 32 to make it lowercase\n bLower[i] = bytes1(uint8(bStr[i]) + 32);\n } else {\n bLower[i] = bStr[i];\n }\n }\n return string(bLower);\n }\n}\n\n\n\n","language":"Solidity","languageVersion":"0.6.12","compilerVersion":"0.6.12","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"9495:7684:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;","srcMapRuntime":"9495:7684:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Collection of functions related to the address type","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Collection of functions related to the address type\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/solidity/BridgeConfigV3_flat.sol\":\"Address\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/solidity/BridgeConfigV3_flat.sol\":{\"keccak256\":\"0xed97c5e2e62a33d867264cf25c64f2215222ad36723fee31796bfd0930a0fffd\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ed38243be38158798b1de0aaa7ba9a22df5f9bca3a1ff9ba814719c9e0391e26\",\"dweb:/ipfs/Qmebz2oFzXzZdE27FNbhhYbvVsDXKPy9pYrBxEVXQDaC4X\"]}},\"version\":1}"},"hashes":{}},"/solidity/BridgeConfigV3_flat.sol:BridgeConfigV3":{"code":"0x60806040523480156200001157600080fd5b506200001f60003362000025565b62000139565b62000031828262000035565b5050565b6000828152602081815260409091206200005a91839062001098620000ae821b17901c565b1562000031576200006a620000ce565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000620000c5836001600160a01b038416620000d2565b90505b92915050565b3390565b6000620000e0838362000121565b6200011857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620000c8565b506000620000c8565b60009081526001919091016020526040902054151590565b612ae180620001496000396000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c80637e355e5e116100f9578063d547741f11610097578063efd7516e11610071578063efd7516e146103c3578063fc7cc4cb146103d6578063fd534b33146103e9578063ff9106c7146103fc576101c4565b8063d547741f1461038a578063ddb543991461039d578063e814157d146103b0576101c4565b8063a217fddf116100d3578063a217fddf14610349578063abaac00814610351578063af611ca014610364578063ca15c87314610377576101c4565b80637e355e5e146103035780639010d07c1461031657806391d1485414610336576101c4565b80633cc1c7e01161016657806359053bfe1161014057806359053bfe146102bb578063684a10b3146102ce57806372fb43d9146102e357806377b8cbf714610242576101c4565b80633cc1c7e014610275578063558dae3a1461029557806358dfe6f1146102a8576101c4565b80632c02799e116101a25780632c02799e146102255780632f2ff15d1461022d578063324980b51461024257806336568abe14610262576101c4565b8063074b7e97146101c95780630a62a9cb146101f2578063248a9ca314610212575b600080fd5b6101dc6101d7366004612551565b610404565b6040516101e99190612725565b60405180910390f35b6102056102003660046125c7565b6105d3565b6040516101e99190612730565b610205610220366004612397565b6105f2565b610205610607565b61024061023b3660046123af565b61060c565b005b610255610250366004612584565b610677565b6040516101e991906129d7565b6102406102703660046123af565b6107cb565b6102886102833660046122e6565b610841565b6040516101e99190612739565b6102556102a33660046122e6565b61085d565b6102556102b6366004612551565b610942565b6101dc6102c9366004612417565b610b25565b6102d6610b87565b6040516101e991906126a7565b6102f66102f13660046122e6565b610c2a565b6040516101e9919061298b565b6102f6610311366004612310565b610cb4565b6103296103243660046123f6565b610e0f565b6040516101e99190612686565b6101dc6103443660046123af565b610e27565b610205610e3f565b61024061035f3660046123f6565b610e44565b6101dc610372366004612551565b610e89565b610205610385366004612397565b610e9c565b6102406103983660046123af565b610eb3565b6101dc6103ab3660046124d9565b610f07565b6102556103be366004612584565b611020565b6102886103d1366004612584565b611043565b6102056103e4366004612364565b611051565b6102056103f7366004612397565b611062565b610205611074565b600080610410836110ba565b600081815260026020908152604080832080548251818502810185019093528083529495506060949193909284015b8282101561058257838290600052602060002090600902016040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105065780601f106104db57610100808354040283529160200191610506565b820191906000526020600020905b8154815290600101906020018083116104e957829003601f168201915b5050509183525050600282015460ff908116602080840191909152600384015460408401526004840154606084015260058401546080840152600684015460a0840152600784015460c0840152600890930154808216151560e0840152610100908190049091161515910152908252600192909201910161043f565b50505050905060005b81518110156105c6578181815181106105a057fe5b60200260200101516101000151156105be57600193505050506105ce565b60010161058b565b506000925050505b919050565b60006105e86105e1856110d3565b848461122d565b90505b9392505050565b60009081526020819052604090206002015490565b600381565b60008281526020819052604090206002015461062a90610344611410565b610669576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610660906127a9565b60405180910390fd5b6106738282611414565b5050565b61067f6120aa565b6004600061068c856110ba565b815260200190815260200160002060008381526020019081526020016000206040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561075a5780601f1061072f5761010080835404028352916020019161075a565b820191906000526020600020905b81548152906001019060200180831161073d57829003601f168201915b5050509183525050600282015460ff9081166020830152600383015460408301526004830154606083015260058301546080830152600683015460a0830152600783015460c0830152600890920154808316151560e083015261010090819004909216151591015290505b92915050565b6107d3611410565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610837576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106609061292e565b6106738282611497565b60606105eb6108576108528561151a565b6110d3565b8361168b565b6108656120aa565b6000828152600360205260408120600491906108836108528761151a565b604051610890919061266a565b908152602001604051809103902054815260200190815260200160002060008381526020019081526020016000206040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561075a5780601f1061072f5761010080835404028352916020019161075a565b61094a6120aa565b6000610955836110ba565b600081815260026020908152604080832080548251818502810185019093528083529495506060949193909284015b82821015610ac757838290600052602060002090600902016040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4b5780601f10610a2057610100808354040283529160200191610a4b565b820191906000526020600020905b815481529060010190602001808311610a2e57829003601f168201915b5050509183525050600282015460ff908116602080840191909152600384015460408401526004840154606084015260058401546080840152600684015460a0840152600784015460c0840152600890930154808216151560e08401526101009081900490911615159101529082526001929092019101610984565b50505050905060005b8151811015610b1d57818181518110610ae557fe5b6020026020010151610120015115610b1557818181518110610b0357fe5b602002602001015193505050506105ce565b600101610ad0565b505050919050565b6000610b517f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8533610e27565b610b5a57600080fd5b610b768d8d8d610b698e61151a565b8d8d8d8d8d8d8d8d610f07565b9d9c50505050505050505050505050565b6001546060908067ffffffffffffffff81118015610ba457600080fd5b50604051908082528060200260200182016040528015610bd857816020015b6060815260200190600190039081610bc35790505b50915060005b81811015610c2557610c0660018281548110610bf657fe5b90600052602060002001546116c1565b838281518110610c1257fe5b6020908102919091010152600101610bde565b505090565b610c32612104565b5073ffffffffffffffffffffffffffffffffffffffff918216600090815260056020908152604080832093835292815290829020825160808101845281548516815260018201549281019290925260020154928316918101919091527401000000000000000000000000000000000000000090910460ff161515606082015290565b610cbc612104565b610ce67f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8533610e27565b610d1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610660906128f7565b610d24612104565b50506040805160808101825273ffffffffffffffffffffffffffffffffffffffff8087168083526020808401888152878416858701908152871515606087019081526000948552600584528785208b865290935295909220845181549085167fffffffffffffffffffffffff0000000000000000000000000000000000000000918216178255925160018201559451600290950180549151151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff9690941691909216179390931617909155949350505050565b60008281526020819052604081206105eb90836117cd565b60008281526020819052604081206105eb90836117d9565b600081565b610e6e7f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8533610e27565b610e7757600080fd5b60009182526006602052604090912055565b60006107c5610e97836110ba565b6117fb565b60008181526020819052604081206107c590611843565b600082815260208190526040902060020154610ed190610344611410565b610837576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106609061283d565b6000610f337f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8533610e27565b610f3c57600080fd5b610f446120aa565b610f4d8b6110d3565b816020018190525089816040019060ff16908160ff16815250508881606001818152505087816080018181525050868160a0018181525050858160c0018181525050848160e0018181525050838161010001901515908115158152505082816101200190151590811515815250508b81600001818152505061100e6110078f8f8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506110ba92505050565b8d8361184e565b9e9d5050505050505050505050505050565b6110286120aa565b600082815260036020526040812060049190610883866110d3565b60606105eb610857846110d3565b60006105e86105e16108528661151a565b60009081526006602052604090205490565b7f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8581565b60006105eb8373ffffffffffffffffffffffffffffffffffffffff8416611c77565b60006020825111156110cb57600080fd5b506020015190565b6060808290506060815167ffffffffffffffff811180156110f357600080fd5b506040519080825280601f01601f19166020018201604052801561111e576020820181803683370190505b50905060005b825181101561122557604183828151811061113b57fe5b016020015160f81c108015906111655750605a83828151811061115a57fe5b016020015160f81c11155b156111ca5782818151811061117657fe5b602001015160f81c60f81b60f81c60200160f81b82828151811061119657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535061121d565b8281815181106111d657fe5b602001015160f81c60f81b8282815181106111ed57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053505b600101611124565b509392505050565b60006112376120aa565b6000848152600360205260408082209051600492919061125890899061266a565b908152602001604051809103902054815260200190815260200160002060008581526020019081526020016000206040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113355780601f1061130a57610100808354040283529160200191611335565b820191906000526020600020905b81548152906001019060200180831161131857829003601f168201915b5050509183525050600282015460ff9081166020830152600383015460408301526004830154606083015260058301546080830152600683015460a080840191909152600784015460c0840152600890930154808216151560e08401526101009081900490911615159101528101519091506000906113c6906402540be400906113c0908790611cc1565b90611d15565b90508160e00151811180156113de57508160c0015181105b156113ec5791506105eb9050565b8160c00151811115611404575060c0015190506105eb565b5060e0015190506105eb565b3390565b600082815260208190526040902061142c9082611098565b1561067357611439611410565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020819052604090206114af9082611d61565b15610673576114bc611410565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b604080516028808252606082810190935282919060208201818036833701905050905060005b60148110156116445760008160130360080260020a8573ffffffffffffffffffffffffffffffffffffffff168161157357fe5b0460f81b9050600060108260f81c60ff168161158b57fe5b0460f81b905060008160f81c6010028360f81c0360f81b90506115ad82611d83565b8585600202815181106115bc57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506115f481611d83565b85856002026001018151811061160657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050600190920191506115409050565b5060408051808201909152600281527f307800000000000000000000000000000000000000000000000000000000000060208201526116838183611db1565b949350505050565b60606105eb60036000848152602001908152602001600020846040516116b1919061266a565b9081526020016040518091039020545b606060005b60208160ff1610801561170c5750828160ff16602081106116e357fe5b1a60f81b7fff000000000000000000000000000000000000000000000000000000000000001615155b15611719576001016116c6565b60608160ff1667ffffffffffffffff8111801561173557600080fd5b506040519080825280601f01601f191660200182016040528015611760576020820181803683370190505b50905060005b8260ff168160ff16101561122557848160ff166020811061178357fe5b1a60f81b828260ff168151811061179657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600101611766565b60006105eb8383611ef2565b60006105eb8373ffffffffffffffffffffffffffffffffffffffff8416611f51565b6000805b60015481101561183a57826001828154811061181757fe5b906000526020600020015414156118325760019150506105ce565b6001016117ff565b50600092915050565b60006107c582611f69565b60008381526004602090815260408083208584528252822083518155818401518051859361188392600185019291019061212b565b50604082015160028201805460ff9092167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00928316179055606083015160038301556080830151600483015560a0830151600583015560c0830151600683015560e0830151600783015561010080840151600890930180546101209095015115159091027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff931515949092169390931791909116179055611943846117fb565b61197c576001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6018490555b6000848152600260205260408120905b8154811015611b4857848282815481106119a257fe5b9060005260206000209060090201600001541415611b405760608282815481106119c857fe5b90600052602060002090600902016001018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611a6d5780601f10611a4257610100808354040283529160200191611a6d565b820191906000526020600020905b815481529060010190602001808311611a5057829003601f168201915b50505050509050611a82856020015182611f6d565b611b3e578460200151838381548110611a9757fe5b90600052602060002090600902016001019080519060200190611abb92919061212b565b507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4706003600088815260200190815260200160002082604051611afe919061266a565b90815260408051602092819003830181209390935560008981526003835220908701518992611b2d919061266a565b908152604051908190036020019020555b505b60010161198c565b5080546001818101835560008381526020908190208651600990940201928355808601518051879493611b809390850192019061212b565b5060408281015160028301805460ff9092167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0092831617905560608401516003808501919091556080850151600485015560a0850151600585015560c0850151600685015560e0850151600785015561010080860151600890950180546101209097015115159091027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff95151596909316959095179390931617909255600086815260209182528290209085015191518792611c5b9161266a565b9081526040519081900360200190205550600190509392505050565b6000611c838383611f51565b611cb9575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556107c5565b5060006107c5565b600082611cd0575060006107c5565b82820282848281611cdd57fe5b04146105eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106609061289a565b6000808211611d50576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066090612806565b818381611d5957fe5b049392505050565b60006105eb8373ffffffffffffffffffffffffffffffffffffffff8416611fc6565b6000600a60f883901c1015611da3578160f81c60300160f81b90506105ce565b50605760f891821c01901b90565b805182516060918491849184910167ffffffffffffffff81118015611dd557600080fd5b506040519080825280601f01601f191660200182016040528015611e00576020820181803683370190505b509050806000805b8551821015611e7457858281518110611e1d57fe5b602001015160f81c60f81b838280600101935081518110611e3a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600190910190611e08565b600091505b8451821015611ee557848281518110611e8e57fe5b602001015160f81c60f81b838280600101935081518110611eab57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600190910190611e79565b5090979650505050505050565b81546000908210611f2f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106609061274c565b826000018281548110611f3e57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081604051602001611f80919061266a565b6040516020818303038152906040528051906020012083604051602001611fa7919061266a565b6040516020818303038152906040528051906020012014905092915050565b600081815260018301602052604081205480156120a05783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808301919081019060009087908390811061201757fe5b906000526020600020015490508087600001848154811061203457fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061206457fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506107c5565b60009150506107c5565b6040518061014001604052806000815260200160608152602001600060ff16815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b60408051608081018252600080825260208201819052918101829052606081019190915290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061216c57805160ff1916838001178555612199565b82800160010185558215612199579182015b8281111561219957825182559160200191906001019061217e565b506121a59291506121a9565b5090565b5b808211156121a557600081556001016121aa565b803573ffffffffffffffffffffffffffffffffffffffff811681146107c557600080fd5b803580151581146107c557600080fd5b60008083601f840112612203578182fd5b50813567ffffffffffffffff81111561221a578182fd5b60208301915083602082850101111561223257600080fd5b9250929050565b600082601f830112612249578081fd5b813567ffffffffffffffff80821115612260578283fd5b60405160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f850116820101818110838211171561229e578485fd5b6040528281529250828483016020018610156122b957600080fd5b8260208601602083013760006020848301015250505092915050565b803560ff811681146107c557600080fd5b600080604083850312156122f8578182fd5b61230284846121be565b946020939093013593505050565b60008060008060808587031215612325578182fd5b61232f86866121be565b93506020850135925061234586604087016121be565b915060608501358015158114612359578182fd5b939692955090935050565b600080600060608486031215612378578283fd5b61238285856121be565b95602085013595506040909401359392505050565b6000602082840312156123a8578081fd5b5035919050565b600080604083850312156123c1578182fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff811681146123eb578182fd5b809150509250929050565b60008060408385031215612408578182fd5b50508035926020909101359150565b6000806000806000806000806000806000806101608d8f031215612439578788fd5b67ffffffffffffffff8d35111561244e578788fd5b61245b8e8e358f016121f2565b909c509a5060208d013599506124748e60408f016121be565b98506124838e60608f016122d5565b975060808d0135965060a08d0135955060c08d0135945060e08d013593506101008d013592506124b78e6101208f016121e2565b91506124c78e6101408f016121e2565b90509295989b509295989b509295989b565b6000806000806000806000806000806000806101608d8f0312156124fb578081fd5b67ffffffffffffffff8d351115612510578081fd5b61251d8e8e358f016121f2565b909c509a5060208d0135995067ffffffffffffffff60408e01351115612541578081fd5b6124748e60408f01358f01612239565b600060208284031215612562578081fd5b813567ffffffffffffffff811115612578578182fd5b61168384828501612239565b60008060408385031215612596578182fd5b823567ffffffffffffffff8111156125ac578283fd5b6125b885828601612239565b95602094909401359450505050565b6000806000606084860312156125db578081fd5b833567ffffffffffffffff8111156125f1578182fd5b6125fd86828701612239565b9660208601359650604090950135949350505050565b15159052565b60008151808452612631816020860160208601612a7b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60ff169052565b6000825161267c818460208701612a7b565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b6000602080830181845280855180835260408601915060408482028701019250838701855b82811015612718577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452612706858351612619565b945092850192908501906001016126cc565b5092979650505050505050565b901515815260200190565b90815260200190565b6000602082526105eb6020830184612619565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60408201527f7700000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601c908201527f43616c6c6572206973206e6f7420427269646765204d616e6167657200000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b600060808201905073ffffffffffffffffffffffffffffffffffffffff808451168352602084015160208401528060408501511660408401525060608301511515606083015292915050565b600060208252825160208301526020830151610140806040850152612a00610160850183612619565b91506040850151612a146060860182612663565b5060608501516080850152608085015160a085015260a085015160c085015260c085015160e085015260e0850151610100818187015280870151915050610120612a6081870183612613565b8601519050612a7185830182612613565b5090949350505050565b60005b83811015612a96578181015183820152602001612a7e565b83811115612aa5576000848401525b5050505056fea2646970667358221220183585375986449f7549fd6c95f8d4314e8678e4a8d4e150abebb12f59796dca64736f6c634300060c0033","runtime-code":"0x608060405234801561001057600080fd5b50600436106101c45760003560e01c80637e355e5e116100f9578063d547741f11610097578063efd7516e11610071578063efd7516e146103c3578063fc7cc4cb146103d6578063fd534b33146103e9578063ff9106c7146103fc576101c4565b8063d547741f1461038a578063ddb543991461039d578063e814157d146103b0576101c4565b8063a217fddf116100d3578063a217fddf14610349578063abaac00814610351578063af611ca014610364578063ca15c87314610377576101c4565b80637e355e5e146103035780639010d07c1461031657806391d1485414610336576101c4565b80633cc1c7e01161016657806359053bfe1161014057806359053bfe146102bb578063684a10b3146102ce57806372fb43d9146102e357806377b8cbf714610242576101c4565b80633cc1c7e014610275578063558dae3a1461029557806358dfe6f1146102a8576101c4565b80632c02799e116101a25780632c02799e146102255780632f2ff15d1461022d578063324980b51461024257806336568abe14610262576101c4565b8063074b7e97146101c95780630a62a9cb146101f2578063248a9ca314610212575b600080fd5b6101dc6101d7366004612551565b610404565b6040516101e99190612725565b60405180910390f35b6102056102003660046125c7565b6105d3565b6040516101e99190612730565b610205610220366004612397565b6105f2565b610205610607565b61024061023b3660046123af565b61060c565b005b610255610250366004612584565b610677565b6040516101e991906129d7565b6102406102703660046123af565b6107cb565b6102886102833660046122e6565b610841565b6040516101e99190612739565b6102556102a33660046122e6565b61085d565b6102556102b6366004612551565b610942565b6101dc6102c9366004612417565b610b25565b6102d6610b87565b6040516101e991906126a7565b6102f66102f13660046122e6565b610c2a565b6040516101e9919061298b565b6102f6610311366004612310565b610cb4565b6103296103243660046123f6565b610e0f565b6040516101e99190612686565b6101dc6103443660046123af565b610e27565b610205610e3f565b61024061035f3660046123f6565b610e44565b6101dc610372366004612551565b610e89565b610205610385366004612397565b610e9c565b6102406103983660046123af565b610eb3565b6101dc6103ab3660046124d9565b610f07565b6102556103be366004612584565b611020565b6102886103d1366004612584565b611043565b6102056103e4366004612364565b611051565b6102056103f7366004612397565b611062565b610205611074565b600080610410836110ba565b600081815260026020908152604080832080548251818502810185019093528083529495506060949193909284015b8282101561058257838290600052602060002090600902016040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105065780601f106104db57610100808354040283529160200191610506565b820191906000526020600020905b8154815290600101906020018083116104e957829003601f168201915b5050509183525050600282015460ff908116602080840191909152600384015460408401526004840154606084015260058401546080840152600684015460a0840152600784015460c0840152600890930154808216151560e0840152610100908190049091161515910152908252600192909201910161043f565b50505050905060005b81518110156105c6578181815181106105a057fe5b60200260200101516101000151156105be57600193505050506105ce565b60010161058b565b506000925050505b919050565b60006105e86105e1856110d3565b848461122d565b90505b9392505050565b60009081526020819052604090206002015490565b600381565b60008281526020819052604090206002015461062a90610344611410565b610669576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610660906127a9565b60405180910390fd5b6106738282611414565b5050565b61067f6120aa565b6004600061068c856110ba565b815260200190815260200160002060008381526020019081526020016000206040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561075a5780601f1061072f5761010080835404028352916020019161075a565b820191906000526020600020905b81548152906001019060200180831161073d57829003601f168201915b5050509183525050600282015460ff9081166020830152600383015460408301526004830154606083015260058301546080830152600683015460a0830152600783015460c0830152600890920154808316151560e083015261010090819004909216151591015290505b92915050565b6107d3611410565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610837576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106609061292e565b6106738282611497565b60606105eb6108576108528561151a565b6110d3565b8361168b565b6108656120aa565b6000828152600360205260408120600491906108836108528761151a565b604051610890919061266a565b908152602001604051809103902054815260200190815260200160002060008381526020019081526020016000206040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561075a5780601f1061072f5761010080835404028352916020019161075a565b61094a6120aa565b6000610955836110ba565b600081815260026020908152604080832080548251818502810185019093528083529495506060949193909284015b82821015610ac757838290600052602060002090600902016040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4b5780601f10610a2057610100808354040283529160200191610a4b565b820191906000526020600020905b815481529060010190602001808311610a2e57829003601f168201915b5050509183525050600282015460ff908116602080840191909152600384015460408401526004840154606084015260058401546080840152600684015460a0840152600784015460c0840152600890930154808216151560e08401526101009081900490911615159101529082526001929092019101610984565b50505050905060005b8151811015610b1d57818181518110610ae557fe5b6020026020010151610120015115610b1557818181518110610b0357fe5b602002602001015193505050506105ce565b600101610ad0565b505050919050565b6000610b517f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8533610e27565b610b5a57600080fd5b610b768d8d8d610b698e61151a565b8d8d8d8d8d8d8d8d610f07565b9d9c50505050505050505050505050565b6001546060908067ffffffffffffffff81118015610ba457600080fd5b50604051908082528060200260200182016040528015610bd857816020015b6060815260200190600190039081610bc35790505b50915060005b81811015610c2557610c0660018281548110610bf657fe5b90600052602060002001546116c1565b838281518110610c1257fe5b6020908102919091010152600101610bde565b505090565b610c32612104565b5073ffffffffffffffffffffffffffffffffffffffff918216600090815260056020908152604080832093835292815290829020825160808101845281548516815260018201549281019290925260020154928316918101919091527401000000000000000000000000000000000000000090910460ff161515606082015290565b610cbc612104565b610ce67f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8533610e27565b610d1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610660906128f7565b610d24612104565b50506040805160808101825273ffffffffffffffffffffffffffffffffffffffff8087168083526020808401888152878416858701908152871515606087019081526000948552600584528785208b865290935295909220845181549085167fffffffffffffffffffffffff0000000000000000000000000000000000000000918216178255925160018201559451600290950180549151151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff9690941691909216179390931617909155949350505050565b60008281526020819052604081206105eb90836117cd565b60008281526020819052604081206105eb90836117d9565b600081565b610e6e7f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8533610e27565b610e7757600080fd5b60009182526006602052604090912055565b60006107c5610e97836110ba565b6117fb565b60008181526020819052604081206107c590611843565b600082815260208190526040902060020154610ed190610344611410565b610837576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106609061283d565b6000610f337f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8533610e27565b610f3c57600080fd5b610f446120aa565b610f4d8b6110d3565b816020018190525089816040019060ff16908160ff16815250508881606001818152505087816080018181525050868160a0018181525050858160c0018181525050848160e0018181525050838161010001901515908115158152505082816101200190151590811515815250508b81600001818152505061100e6110078f8f8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506110ba92505050565b8d8361184e565b9e9d5050505050505050505050505050565b6110286120aa565b600082815260036020526040812060049190610883866110d3565b60606105eb610857846110d3565b60006105e86105e16108528661151a565b60009081526006602052604090205490565b7f4370dcf3e42e4d5b773a451bb8390ee8e7308f47681d1414cff87c2ad0512c8581565b60006105eb8373ffffffffffffffffffffffffffffffffffffffff8416611c77565b60006020825111156110cb57600080fd5b506020015190565b6060808290506060815167ffffffffffffffff811180156110f357600080fd5b506040519080825280601f01601f19166020018201604052801561111e576020820181803683370190505b50905060005b825181101561122557604183828151811061113b57fe5b016020015160f81c108015906111655750605a83828151811061115a57fe5b016020015160f81c11155b156111ca5782818151811061117657fe5b602001015160f81c60f81b60f81c60200160f81b82828151811061119657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535061121d565b8281815181106111d657fe5b602001015160f81c60f81b8282815181106111ed57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053505b600101611124565b509392505050565b60006112376120aa565b6000848152600360205260408082209051600492919061125890899061266a565b908152602001604051809103902054815260200190815260200160002060008581526020019081526020016000206040518061014001604052908160008201548152602001600182018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113355780601f1061130a57610100808354040283529160200191611335565b820191906000526020600020905b81548152906001019060200180831161131857829003601f168201915b5050509183525050600282015460ff9081166020830152600383015460408301526004830154606083015260058301546080830152600683015460a080840191909152600784015460c0840152600890930154808216151560e08401526101009081900490911615159101528101519091506000906113c6906402540be400906113c0908790611cc1565b90611d15565b90508160e00151811180156113de57508160c0015181105b156113ec5791506105eb9050565b8160c00151811115611404575060c0015190506105eb565b5060e0015190506105eb565b3390565b600082815260208190526040902061142c9082611098565b1561067357611439611410565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020819052604090206114af9082611d61565b15610673576114bc611410565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b604080516028808252606082810190935282919060208201818036833701905050905060005b60148110156116445760008160130360080260020a8573ffffffffffffffffffffffffffffffffffffffff168161157357fe5b0460f81b9050600060108260f81c60ff168161158b57fe5b0460f81b905060008160f81c6010028360f81c0360f81b90506115ad82611d83565b8585600202815181106115bc57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506115f481611d83565b85856002026001018151811061160657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050600190920191506115409050565b5060408051808201909152600281527f307800000000000000000000000000000000000000000000000000000000000060208201526116838183611db1565b949350505050565b60606105eb60036000848152602001908152602001600020846040516116b1919061266a565b9081526020016040518091039020545b606060005b60208160ff1610801561170c5750828160ff16602081106116e357fe5b1a60f81b7fff000000000000000000000000000000000000000000000000000000000000001615155b15611719576001016116c6565b60608160ff1667ffffffffffffffff8111801561173557600080fd5b506040519080825280601f01601f191660200182016040528015611760576020820181803683370190505b50905060005b8260ff168160ff16101561122557848160ff166020811061178357fe5b1a60f81b828260ff168151811061179657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600101611766565b60006105eb8383611ef2565b60006105eb8373ffffffffffffffffffffffffffffffffffffffff8416611f51565b6000805b60015481101561183a57826001828154811061181757fe5b906000526020600020015414156118325760019150506105ce565b6001016117ff565b50600092915050565b60006107c582611f69565b60008381526004602090815260408083208584528252822083518155818401518051859361188392600185019291019061212b565b50604082015160028201805460ff9092167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00928316179055606083015160038301556080830151600483015560a0830151600583015560c0830151600683015560e0830151600783015561010080840151600890930180546101209095015115159091027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff931515949092169390931791909116179055611943846117fb565b61197c576001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6018490555b6000848152600260205260408120905b8154811015611b4857848282815481106119a257fe5b9060005260206000209060090201600001541415611b405760608282815481106119c857fe5b90600052602060002090600902016001018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611a6d5780601f10611a4257610100808354040283529160200191611a6d565b820191906000526020600020905b815481529060010190602001808311611a5057829003601f168201915b50505050509050611a82856020015182611f6d565b611b3e578460200151838381548110611a9757fe5b90600052602060002090600902016001019080519060200190611abb92919061212b565b507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4706003600088815260200190815260200160002082604051611afe919061266a565b90815260408051602092819003830181209390935560008981526003835220908701518992611b2d919061266a565b908152604051908190036020019020555b505b60010161198c565b5080546001818101835560008381526020908190208651600990940201928355808601518051879493611b809390850192019061212b565b5060408281015160028301805460ff9092167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0092831617905560608401516003808501919091556080850151600485015560a0850151600585015560c0850151600685015560e0850151600785015561010080860151600890950180546101209097015115159091027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff95151596909316959095179390931617909255600086815260209182528290209085015191518792611c5b9161266a565b9081526040519081900360200190205550600190509392505050565b6000611c838383611f51565b611cb9575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556107c5565b5060006107c5565b600082611cd0575060006107c5565b82820282848281611cdd57fe5b04146105eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106609061289a565b6000808211611d50576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066090612806565b818381611d5957fe5b049392505050565b60006105eb8373ffffffffffffffffffffffffffffffffffffffff8416611fc6565b6000600a60f883901c1015611da3578160f81c60300160f81b90506105ce565b50605760f891821c01901b90565b805182516060918491849184910167ffffffffffffffff81118015611dd557600080fd5b506040519080825280601f01601f191660200182016040528015611e00576020820181803683370190505b509050806000805b8551821015611e7457858281518110611e1d57fe5b602001015160f81c60f81b838280600101935081518110611e3a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600190910190611e08565b600091505b8451821015611ee557848281518110611e8e57fe5b602001015160f81c60f81b838280600101935081518110611eab57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600190910190611e79565b5090979650505050505050565b81546000908210611f2f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106609061274c565b826000018281548110611f3e57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081604051602001611f80919061266a565b6040516020818303038152906040528051906020012083604051602001611fa7919061266a565b6040516020818303038152906040528051906020012014905092915050565b600081815260018301602052604081205480156120a05783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808301919081019060009087908390811061201757fe5b906000526020600020015490508087600001848154811061203457fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061206457fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506107c5565b60009150506107c5565b6040518061014001604052806000815260200160608152602001600060ff16815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b60408051608081018252600080825260208201819052918101829052606081019190915290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061216c57805160ff1916838001178555612199565b82800160010185558215612199579182015b8281111561219957825182559160200191906001019061217e565b506121a59291506121a9565b5090565b5b808211156121a557600081556001016121aa565b803573ffffffffffffffffffffffffffffffffffffffff811681146107c557600080fd5b803580151581146107c557600080fd5b60008083601f840112612203578182fd5b50813567ffffffffffffffff81111561221a578182fd5b60208301915083602082850101111561223257600080fd5b9250929050565b600082601f830112612249578081fd5b813567ffffffffffffffff80821115612260578283fd5b60405160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f850116820101818110838211171561229e578485fd5b6040528281529250828483016020018610156122b957600080fd5b8260208601602083013760006020848301015250505092915050565b803560ff811681146107c557600080fd5b600080604083850312156122f8578182fd5b61230284846121be565b946020939093013593505050565b60008060008060808587031215612325578182fd5b61232f86866121be565b93506020850135925061234586604087016121be565b915060608501358015158114612359578182fd5b939692955090935050565b600080600060608486031215612378578283fd5b61238285856121be565b95602085013595506040909401359392505050565b6000602082840312156123a8578081fd5b5035919050565b600080604083850312156123c1578182fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff811681146123eb578182fd5b809150509250929050565b60008060408385031215612408578182fd5b50508035926020909101359150565b6000806000806000806000806000806000806101608d8f031215612439578788fd5b67ffffffffffffffff8d35111561244e578788fd5b61245b8e8e358f016121f2565b909c509a5060208d013599506124748e60408f016121be565b98506124838e60608f016122d5565b975060808d0135965060a08d0135955060c08d0135945060e08d013593506101008d013592506124b78e6101208f016121e2565b91506124c78e6101408f016121e2565b90509295989b509295989b509295989b565b6000806000806000806000806000806000806101608d8f0312156124fb578081fd5b67ffffffffffffffff8d351115612510578081fd5b61251d8e8e358f016121f2565b909c509a5060208d0135995067ffffffffffffffff60408e01351115612541578081fd5b6124748e60408f01358f01612239565b600060208284031215612562578081fd5b813567ffffffffffffffff811115612578578182fd5b61168384828501612239565b60008060408385031215612596578182fd5b823567ffffffffffffffff8111156125ac578283fd5b6125b885828601612239565b95602094909401359450505050565b6000806000606084860312156125db578081fd5b833567ffffffffffffffff8111156125f1578182fd5b6125fd86828701612239565b9660208601359650604090950135949350505050565b15159052565b60008151808452612631816020860160208601612a7b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60ff169052565b6000825161267c818460208701612a7b565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b6000602080830181845280855180835260408601915060408482028701019250838701855b82811015612718577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452612706858351612619565b945092850192908501906001016126cc565b5092979650505050505050565b901515815260200190565b90815260200190565b6000602082526105eb6020830184612619565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60408201527f7700000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601c908201527f43616c6c6572206973206e6f7420427269646765204d616e6167657200000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b600060808201905073ffffffffffffffffffffffffffffffffffffffff808451168352602084015160208401528060408501511660408401525060608301511515606083015292915050565b600060208252825160208301526020830151610140806040850152612a00610160850183612619565b91506040850151612a146060860182612663565b5060608501516080850152608085015160a085015260a085015160c085015260c085015160e085015260e0850151610100818187015280870151915050610120612a6081870183612613565b8601519050612a7185830182612613565b5090949350505050565b60005b83811015612a96578181015183820152602001612a7e565b83811115612aa5576000848401525b5050505056fea2646970667358221220183585375986449f7549fd6c95f8d4314e8678e4a8d4e150abebb12f59796dca64736f6c634300060c0033","info":{"source":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\n\n\n\n\n\n\n\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping (bytes32 =\u003e uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) { // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n require(set._values.length \u003e index, \"EnumerableSet: index out of bounds\");\n return set._values[index];\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n}\n\n\n\n\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\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 // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size \u003e 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 \u003e= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\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(address target, bytes memory data, string memory errorMessage) 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(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\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(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\n\n\n\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\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 AccessControl is Context {\n using EnumerableSet for EnumerableSet.AddressSet;\n using Address for address;\n\n struct RoleData {\n EnumerableSet.AddressSet members;\n bytes32 adminRole;\n }\n\n mapping (bytes32 =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\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 {_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) public view returns (bool) {\n return _roles[role].members.contains(account);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n return _roles[role].members.length();\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n return _roles[role].members.at(index);\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 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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\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 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) public virtual {\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 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 emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\n _roles[role].adminRole = adminRole;\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (_roles[role].members.add(account)) {\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (_roles[role].members.remove(account)) {\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n\n\n\n\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c \u003c a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b \u003e a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c \u003e= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003c= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003c= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a % b;\n }\n}\n\n\n/**\n * @title BridgeConfig contract\n * @notice This token is used for configuring different tokens on the bridge and mapping them across chains.\n **/\n\ncontract BridgeConfigV3 is AccessControl {\n using SafeMath for uint256;\n bytes32 public constant BRIDGEMANAGER_ROLE = keccak256(\"BRIDGEMANAGER_ROLE\");\n bytes32[] private _allTokenIDs;\n mapping(bytes32 =\u003e Token[]) private _allTokens; // key is tokenID\n mapping(uint256 =\u003e mapping(string =\u003e bytes32)) private _tokenIDMap; // key is chainID,tokenAddress\n mapping(bytes32 =\u003e mapping(uint256 =\u003e Token)) private _tokens; // key is tokenID,chainID\n mapping(address =\u003e mapping(uint256 =\u003e Pool)) private _pool; // key is tokenAddress,chainID\n mapping(uint256 =\u003e uint256) private _maxGasPrice; // key is tokenID,chainID\n uint256 public constant bridgeConfigVersion = 3;\n\n // the denominator used to calculate fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // this struct must be initialized using setTokenConfig for each token that directly interacts with the bridge\n struct Token {\n uint256 chainId;\n string tokenAddress;\n uint8 tokenDecimals;\n uint256 maxSwap;\n uint256 minSwap;\n uint256 swapFee;\n uint256 maxSwapFee;\n uint256 minSwapFee;\n bool hasUnderlying;\n bool isUnderlying;\n }\n\n struct Pool {\n address tokenAddress;\n uint256 chainId;\n address poolAddress;\n bool metaswap;\n }\n\n constructor() public {\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n }\n\n /**\n * @notice Returns a list of all existing token IDs converted to strings\n */\n function getAllTokenIDs() public view returns (string[] memory result) {\n uint256 length = _allTokenIDs.length;\n result = new string[](length);\n for (uint256 i = 0; i \u003c length; ++i) {\n result[i] = toString(_allTokenIDs[i]);\n }\n }\n\n function _getTokenID(string memory tokenAddress, uint256 chainID) internal view returns (string memory) {\n return toString(_tokenIDMap[chainID][tokenAddress]);\n }\n\n function getTokenID(string memory tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(tokenAddress), chainID);\n }\n\n /**\n * @notice Returns the token ID (string) of the cross-chain token inputted\n * @param tokenAddress address of token to get ID for\n * @param chainID chainID of which to get token ID for\n */\n function getTokenID(address tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(toString(tokenAddress)), chainID);\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getToken(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getTokenByID(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns token config struct, given an address and chainID\n * @param tokenAddress Matches the token ID by using a combo of address + chain ID\n * @param chainID Chain ID of which token to get config for\n */\n function getTokenByAddress(string memory tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(tokenAddress)]][chainID];\n }\n\n function getTokenByEVMAddress(address tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(toString(tokenAddress))]][chainID];\n }\n\n /**\n * @notice Returns true if the token has an underlying token -- meaning the token is deposited into the bridge\n * @param tokenID String to check if it is a withdraw/underlying token\n */\n function hasUnderlyingToken(string memory tokenID) public view returns (bool) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].hasUnderlying) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Returns which token is the underlying token to withdraw\n * @param tokenID string token ID\n */\n function getUnderlyingToken(string memory tokenID) public view returns (Token memory token) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].isUnderlying) {\n return _mcTokens[i];\n }\n }\n }\n\n /**\n @notice Public function returning if token ID exists given a string\n */\n function isTokenIDExist(string memory tokenID) public view returns (bool) {\n return _isTokenIDExist(toBytes32(tokenID));\n }\n\n /**\n @notice Internal function returning if token ID exists given bytes32 version of the ID\n */\n function _isTokenIDExist(bytes32 tokenID) internal view returns (bool) {\n for (uint256 i = 0; i \u003c _allTokenIDs.length; ++i) {\n if (_allTokenIDs[i] == tokenID) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Internal function which handles logic of setting token ID and dealing with mappings\n * @param tokenID bytes32 version of ID\n * @param chainID which chain to set the token config for\n * @param tokenToAdd Token object to set the mapping to\n */\n function _setTokenConfig(\n bytes32 tokenID,\n uint256 chainID,\n Token memory tokenToAdd\n ) internal returns (bool) {\n _tokens[tokenID][chainID] = tokenToAdd;\n if (!_isTokenIDExist(tokenID)) {\n _allTokenIDs.push(tokenID);\n }\n\n Token[] storage _mcTokens = _allTokens[tokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].chainId == chainID) {\n string memory oldToken = _mcTokens[i].tokenAddress;\n if (!compareStrings(tokenToAdd.tokenAddress, oldToken)) {\n _mcTokens[i].tokenAddress = tokenToAdd.tokenAddress;\n _tokenIDMap[chainID][oldToken] = keccak256(\"\");\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n }\n }\n }\n _mcTokens.push(tokenToAdd);\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n return true;\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n address tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n return\n setTokenConfig(\n tokenID,\n chainID,\n toString(tokenAddress),\n tokenDecimals,\n maxSwap,\n minSwap,\n swapFee,\n maxSwapFee,\n minSwapFee,\n hasUnderlying,\n isUnderlying\n );\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n string memory tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n Token memory tokenToAdd;\n tokenToAdd.tokenAddress = _toLower(tokenAddress);\n tokenToAdd.tokenDecimals = tokenDecimals;\n tokenToAdd.maxSwap = maxSwap;\n tokenToAdd.minSwap = minSwap;\n tokenToAdd.swapFee = swapFee;\n tokenToAdd.maxSwapFee = maxSwapFee;\n tokenToAdd.minSwapFee = minSwapFee;\n tokenToAdd.hasUnderlying = hasUnderlying;\n tokenToAdd.isUnderlying = isUnderlying;\n tokenToAdd.chainId = chainID;\n\n return _setTokenConfig(toBytes32(tokenID), chainID, tokenToAdd);\n }\n\n function _calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) internal view returns (uint256) {\n Token memory token = _tokens[_tokenIDMap[chainID][tokenAddress]][chainID];\n uint256 calculatedSwapFee = amount.mul(token.swapFee).div(FEE_DENOMINATOR);\n if (calculatedSwapFee \u003e token.minSwapFee \u0026\u0026 calculatedSwapFee \u003c token.maxSwapFee) {\n return calculatedSwapFee;\n } else if (calculatedSwapFee \u003e token.maxSwapFee) {\n return token.maxSwapFee;\n } else {\n return token.minSwapFee;\n }\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(tokenAddress), chainID, amount);\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n address tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(toString(tokenAddress)), chainID, amount);\n }\n\n // GAS PRICING\n\n /**\n * @notice sets the max gas price for a chain\n */\n function setMaxGasPrice(uint256 chainID, uint256 maxPrice) public {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n _maxGasPrice[chainID] = maxPrice;\n }\n\n /**\n * @notice gets the max gas price for a chain\n */\n function getMaxGasPrice(uint256 chainID) public view returns (uint256) {\n return _maxGasPrice[chainID];\n }\n\n // POOL CONFIG\n\n function getPoolConfig(address tokenAddress, uint256 chainID) external view returns (Pool memory) {\n return _pool[tokenAddress][chainID];\n }\n\n function setPoolConfig(\n address tokenAddress,\n uint256 chainID,\n address poolAddress,\n bool metaswap\n ) external returns (Pool memory) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender), \"Caller is not Bridge Manager\");\n Pool memory newPool = Pool(tokenAddress, chainID, poolAddress, metaswap);\n _pool[tokenAddress][chainID] = newPool;\n return newPool;\n }\n\n // UTILITY FUNCTIONS\n\n function toString(bytes32 data) internal pure returns (string memory) {\n uint8 i = 0;\n while (i \u003c 32 \u0026\u0026 data[i] != 0) {\n ++i;\n }\n bytes memory bs = new bytes(i);\n for (uint8 j = 0; j \u003c i; ++j) {\n bs[j] = data[j];\n }\n return string(bs);\n }\n\n // toBytes32 converts a string to a bytes 32\n function toBytes32(string memory str) internal pure returns (bytes32 result) {\n require(bytes(str).length \u003c= 32);\n assembly {\n result := mload(add(str, 32))\n }\n }\n\n function toString(address x) internal pure returns (string memory) {\n bytes memory s = new bytes(40);\n for (uint256 i = 0; i \u003c 20; i++) {\n bytes1 b = bytes1(uint8(uint256(uint160(x)) / (2**(8 * (19 - i)))));\n bytes1 hi = bytes1(uint8(b) / 16);\n bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));\n s[2 * i] = char(hi);\n s[2 * i + 1] = char(lo);\n }\n\n string memory addrPrefix = \"0x\";\n\n return concat(addrPrefix, string(s));\n }\n\n function concat(string memory _x, string memory _y) internal pure returns (string memory) {\n bytes memory _xBytes = bytes(_x);\n bytes memory _yBytes = bytes(_y);\n\n string memory _tmpValue = new string(_xBytes.length + _yBytes.length);\n bytes memory _newValue = bytes(_tmpValue);\n\n uint256 i;\n uint256 j;\n\n for (i = 0; i \u003c _xBytes.length; i++) {\n _newValue[j++] = _xBytes[i];\n }\n\n for (i = 0; i \u003c _yBytes.length; i++) {\n _newValue[j++] = _yBytes[i];\n }\n\n return string(_newValue);\n }\n\n function char(bytes1 b) internal pure returns (bytes1 c) {\n if (uint8(b) \u003c 10) {\n c = bytes1(uint8(b) + 0x30);\n } else {\n c = bytes1(uint8(b) + 0x57);\n }\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function _toLower(string memory str) internal pure returns (string memory) {\n bytes memory bStr = bytes(str);\n bytes memory bLower = new bytes(bStr.length);\n for (uint256 i = 0; i \u003c bStr.length; i++) {\n // Uppercase character...\n if ((uint8(bStr[i]) \u003e= 65) \u0026\u0026 (uint8(bStr[i]) \u003c= 90)) {\n // So we add 32 to make it lowercase\n bLower[i] = bytes1(uint8(bStr[i]) + 32);\n } else {\n bLower[i] = bStr[i];\n }\n }\n return string(bLower);\n }\n}\n\n\n\n","language":"Solidity","languageVersion":"0.6.12","compilerVersion":"0.6.12","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"32619:16649:0:-:0;;;34052:80;;;;;;;;;-1:-1:-1;34083:42:0;19668:4;34114:10;34083;:42::i;:::-;32619:16649;;24484:110;24562:25;24573:4;24579:7;24562:10;:25::i;:::-;24484:110;;:::o;24921:184::-;24994:6;:12;;;;;;;;;;;:33;;25019:7;;24994:24;;;;;:33;;:::i;:::-;24990:109;;;25075:12;:10;:12::i;:::-;-1:-1:-1;;;;;25048:40:0;25066:7;-1:-1:-1;;;;;25048:40:0;25060:4;25048:40;;;;;;;;;;24921:184;;:::o;6463:150::-;6533:4;6556:50;6561:3;-1:-1:-1;;;;;6581:23:0;;6556:4;:50::i;:::-;6549:57;;6463:150;;;;;:::o;17717:104::-;17804:10;17717:104;:::o;1674:404::-;1737:4;1758:21;1768:3;1773:5;1758:9;:21::i;:::-;1753:319;;-1:-1:-1;1795:23:0;;;;;;;;:11;:23;;;;;;;;;;;;;1975:18;;1953:19;;;:12;;;:19;;;;;;:40;;;;2007:11;;1753:319;-1:-1:-1;2056:5:0;2049:12;;3839:127;3912:4;3935:19;;;:12;;;;;:19;;;;;;:24;;;3839:127::o;32619:16649::-;;;;;;;","srcMapRuntime":"32619:16649:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;36855:375;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;44619:231;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;22178:112::-;;;;;;:::i;:::-;;:::i;33257:47::-;;;:::i;22540:223::-;;;;;;:::i;:::-;;:::i;:::-;;35455:159;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;23714:205::-;;;;;;:::i;:::-;;:::i;35073:173::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;36437:206::-;;;;;;:::i;:::-;;:::i;37361:374::-;;;;;;:::i;:::-;;:::i;40681:790::-;;;;;;:::i;:::-;;:::i;34231:271::-;;;:::i;:::-;;;;;;;:::i;46029:150::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;46185:418::-;;;;;;:::i;:::-;;:::i;21861:136::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;20846:137::-;;;;;;:::i;:::-;;:::i;19623:49::-;;;:::i;45642:173::-;;;;;;:::i;:::-;;:::i;37830:133::-;;;;;;:::i;:::-;;:::i;21151:125::-;;;;;;:::i;:::-;;:::i;22997:226::-;;;;;;:::i;:::-;;:::i;42555:979::-;;;;;;:::i;:::-;;:::i;36232:199::-;;;;;;:::i;:::-;;:::i;34686:169::-;;;;;;:::i;:::-;;:::i;45315:235::-;;;;;;:::i;:::-;;:::i;45887:116::-;;;;;;:::i;:::-;;:::i;32698:76::-;;;:::i;36855:375::-;36927:4;36943:20;36966:18;36976:7;36966:9;:18::i;:::-;37021:24;;;;:10;:24;;;;;;;;36994:51;;;;;;;;;;;;;;;;;36943:41;;-1:-1:-1;36994:24:0;;:51;;37021:24;;36994:51;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;36994:51:0;;;-1:-1:-1;;36994:51:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;37060:9;37055:147;37079:9;:16;37075:1;:20;37055:147;;;37120:9;37130:1;37120:12;;;;;;;;;;;;;;:26;;;37116:76;;;37173:4;37166:11;;;;;;;37116:76;37097:3;;37055:147;;;;37218:5;37211:12;;;;36855:375;;;;:::o;44619:231::-;44759:7;44785:58;44803:22;44812:12;44803:8;:22::i;:::-;44827:7;44836:6;44785:17;:58::i;:::-;44778:65;;44619:231;;;;;;:::o;22178:112::-;22235:7;22261:12;;;;;;;;;;:22;;;;22178:112::o;33257:47::-;33303:1;33257:47;:::o;22540:223::-;22631:6;:12;;;;;;;;;;:22;;;22623:45;;22655:12;:10;:12::i;22623:45::-;22615:105;;;;;;;;;;;;:::i;:::-;;;;;;;;;22731:25;22742:4;22748:7;22731:10;:25::i;:::-;22540:223;;:::o;35455:159::-;35534:18;;:::i;:::-;35571:7;:27;35579:18;35589:7;35579:9;:18::i;:::-;35571:27;;;;;;;;;;;:36;35599:7;35571:36;;;;;;;;;;;35564:43;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;35564:43:0;;;-1:-1:-1;;35564:43:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;35455:159:0;;;;;:::o;23714:205::-;23811:12;:10;:12::i;:::-;23800:23;;:7;:23;;;23792:83;;;;;;;;;;;;:::i;:::-;23886:26;23898:4;23904:7;23886:11;:26::i;35073:173::-;35153:13;35185:54;35197:32;35206:22;35215:12;35206:8;:22::i;:::-;35197:8;:32::i;:::-;35231:7;35185:11;:54::i;36437:206::-;36527:18;;:::i;:::-;36564:63;36572:20;;;:11;:20;;;;;36564:7;;:63;36593:32;36602:22;36611:12;36602:8;:22::i;36593:32::-;36572:54;;;;;;:::i;:::-;;;;;;;;;;;;;;36564:63;;;;;;;;;;;:72;36628:7;36564:72;;;;;;;;;;;36557:79;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;37361:374;37433:18;;:::i;:::-;37463:20;37486:18;37496:7;37486:9;:18::i;:::-;37541:24;;;;:10;:24;;;;;;;;37514:51;;;;;;;;;;;;;;;;;37463:41;;-1:-1:-1;37514:24:0;;:51;;37541:24;;37514:51;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;37514:51:0;;;-1:-1:-1;;37514:51:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;37580:9;37575:154;37599:9;:16;37595:1;:20;37575:154;;;37640:9;37650:1;37640:12;;;;;;;;;;;;;;:25;;;37636:83;;;37692:9;37702:1;37692:12;;;;;;;;;;;;;;37685:19;;;;;;;37636:83;37617:3;;37575:154;;;;37361:374;;;;;:::o;40681:790::-;41030:4;41054:39;32743:31;41082:10;41054:7;:39::i;:::-;41046:48;;;;;;41123:341;41155:7;;41180;41205:22;41214:12;41205:8;:22::i;:::-;41245:13;41276:7;41301;41326;41351:10;41379;41407:13;41438:12;41123:14;:341::i;:::-;41104:360;40681:790;-1:-1:-1;;;;;;;;;;;;;40681:790:0:o;34231:271::-;34329:12;:19;34278:22;;34329:19;34367:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;34358:29;;34402:9;34397:99;34421:6;34417:1;:10;34397:99;;;34460:25;34469:12;34482:1;34469:15;;;;;;;;;;;;;;;;34460:8;:25::i;:::-;34448:6;34455:1;34448:9;;;;;;;;;;;;;;;;;:37;34429:3;;34397:99;;;;34231:271;;:::o;46029:150::-;46114:11;;:::i;:::-;-1:-1:-1;46144:19:0;;;;;;;;:5;:19;;;;;;;;:28;;;;;;;;;;46137:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;46029:150::o;46185:418::-;46339:11;;:::i;:::-;46370:39;32743:31;46398:10;46370:7;:39::i;:::-;46362:80;;;;;;;;;;;;:::i;:::-;46452:19;;:::i;:::-;-1:-1:-1;;46474:50:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;46534:19:0;;;:5;:19;;;;;:28;;;;;;;;;;:38;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;46185:418;;;;;;:::o;21861:136::-;21934:7;21960:12;;;;;;;;;;:30;;21984:5;21960:23;:30::i;20846:137::-;20915:4;20938:12;;;;;;;;;;:38;;20968:7;20938:29;:38::i;19623:49::-;19668:4;19623:49;:::o;45642:173::-;45726:39;32743:31;45754:10;45726:7;:39::i;:::-;45718:48;;;;;;45776:21;;;;:12;:21;;;;;;:32;45642:173::o;37830:133::-;37898:4;37921:35;37937:18;37947:7;37937:9;:18::i;:::-;37921:15;:35::i;21151:125::-;21214:7;21240:12;;;;;;;;;;:29;;:27;:29::i;22997:226::-;23089:6;:12;;;;;;;;;;:22;;;23081:45;;23113:12;:10;:12::i;23081:45::-;23073:106;;;;;;;;;;;;:::i;42555:979::-;42910:4;42934:39;32743:31;42962:10;42934:7;:39::i;:::-;42926:48;;;;;;42984:23;;:::i;:::-;43043:22;43052:12;43043:8;:22::i;:::-;43017:10;:23;;:48;;;;43102:13;43075:10;:24;;:40;;;;;;;;;;;43146:7;43125:10;:18;;:28;;;;;43184:7;43163:10;:18;;:28;;;;;43222:7;43201:10;:18;;:28;;;;;43263:10;43239;:21;;:34;;;;;43307:10;43283;:21;;:34;;;;;43354:13;43327:10;:24;;:40;;;;;;;;;;;43403:12;43377:10;:23;;:38;;;;;;;;;;;43446:7;43425:10;:18;;:28;;;;;43471:56;43487:18;43497:7;;43487:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;43487:9:0;;-1:-1:-1;;;43487:18:0:i;:::-;43507:7;43516:10;43471:15;:56::i;:::-;43464:63;42555:979;-1:-1:-1;;;;;;;;;;;;;;42555:979:0:o;36232:199::-;36325:18;;:::i;:::-;36362:53;36370:20;;;:11;:20;;;;;36362:7;;:53;36391:22;36400:12;36391:8;:22::i;34686:169::-;34772:13;34804:44;34816:22;34825:12;34816:8;:22::i;45315:235::-;45449:7;45475:68;45493:32;45502:22;45511:12;45502:8;:22::i;45887:116::-;45949:7;45975:21;;;:12;:21;;;;;;;45887:116::o;32698:76::-;32743:31;32698:76;:::o;6463:150::-;6533:4;6556:50;6561:3;6581:23;;;6556:4;:50::i;47002:197::-;47063:14;47118:2;47103:3;47097:17;:23;;47089:32;;;;;;-1:-1:-1;47179:2:0;47170:12;47164:19;;47140:53::o;48709:557::-;48769:13;48794:17;48820:3;48794:30;;48834:19;48866:4;:11;48856:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;48856:22:0;;48834:44;;48893:9;48888:341;48912:4;:11;48908:1;:15;48888:341;;;49005:2;48993:4;48998:1;48993:7;;;;;;;;;;;;;;48987:20;;;;48986:48;;;49031:2;49019:4;49024:1;49019:7;;;;;;;;;;;;;;49013:20;;48986:48;48982:237;;;49132:4;49137:1;49132:7;;;;;;;;;;;;;;;;49126:14;;49143:2;49126:19;49119:27;;49107:6;49114:1;49107:9;;;;;;;;;;;:39;;;;;;;;;;;48982:237;;;49197:4;49202:1;49197:7;;;;;;;;;;;;;;;;49185:6;49192:1;49185:9;;;;;;;;;;;:19;;;;;;;;;;;48982:237;48925:3;;48888:341;;;-1:-1:-1;49252:6:0;48709:557;-1:-1:-1;;;48709:557:0:o;43540:614::-;43681:7;43700:18;;:::i;:::-;43721:43;43729:20;;;:11;:20;;;;;;:34;;43721:7;;:43;43729:20;:34;;43750:12;;43729:34;:::i;:::-;;;;;;;;;;;;;;43721:43;;;;;;;;;;;:52;43765:7;43721:52;;;;;;;;;;;43700:73;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;43700:73:0;;;-1:-1:-1;;43700:73:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;43822:13;;;43700:73;;-1:-1:-1;43700:73:0;;43811:46;;33497:6;;43811:25;;:6;;:10;:25::i;:::-;:29;;:46::i;:::-;43783:74;;43891:5;:16;;;43871:17;:36;:76;;;;;43931:5;:16;;;43911:17;:36;43871:76;43867:281;;;43970:17;-1:-1:-1;43963:24:0;;-1:-1:-1;43963:24:0;43867:281;44028:5;:16;;;44008:17;:36;44004:144;;;-1:-1:-1;44067:16:0;;;;-1:-1:-1;44060:23:0;;44004:144;-1:-1:-1;44121:16:0;;;;-1:-1:-1;44114:23:0;;17717:104;17804:10;17717:104;:::o;24921:184::-;24994:6;:12;;;;;;;;;;:33;;25019:7;24994:24;:33::i;:::-;24990:109;;;25075:12;:10;:12::i;:::-;25048:40;;25066:7;25048:40;;25060:4;25048:40;;;;;;;;;;24921:184;;:::o;25111:188::-;25185:6;:12;;;;;;;;;;:36;;25213:7;25185:27;:36::i;:::-;25181:112;;;25269:12;:10;:12::i;:::-;25242:40;;25260:7;25242:40;;25254:4;25242:40;;;;;;;;;;25111:188;;:::o;47205:513::-;47299:13;;;47309:2;47299:13;;;47257;47299;;;;;;47257;;47299;;;;;;;;;;;-1:-1:-1;47299:13:0;47282:30;;47327:9;47322:301;47346:2;47342:1;:6;47322:301;;;47369:8;47430:1;47425:2;:6;47420:1;:12;47416:1;:17;47409:1;47393:19;;:41;;;;;;47380:56;;47369:67;;47450:9;47480:2;47475:1;47469:8;;:13;;;;;;;;47462:21;;47450:33;;47497:9;47538:2;47532:9;;47527:2;:14;47522:1;47516:8;;:25;47509:33;;47497:45;;47567:8;47572:2;47567:4;:8::i;:::-;47556:1;47562;47558;:5;47556:8;;;;;;;;;;;:19;;;;;;;;;;;47604:8;47609:2;47604:4;:8::i;:::-;47589:1;47595;47591;:5;47599:1;47591:9;47589:12;;;;;;;;;;;:23;;;;;;;;;;-1:-1:-1;;47350:3:0;;;;;-1:-1:-1;47322:301:0;;-1:-1:-1;47322:301:0;;-1:-1:-1;47633:31:0;;;;;;;;;;;;;;;;;47682:29;47633:31;47708:1;47682:6;:29::i;:::-;47675:36;47205:513;-1:-1:-1;;;;47205:513:0:o;34508:172::-;34597:13;34629:44;34638:11;:20;34650:7;34638:20;;;;;;;;;;;34659:12;34638:34;;;;;;:::i;:::-;;;;;;;;;;;;;;46635:312;46690:13;46715:7;46736:59;46747:2;46743:1;:6;;;:22;;;;;46753:4;46758:1;46753:7;;;;;;;;;;;;:12;;;;46743:22;46736:59;;;46781:3;;46736:59;;;46804:15;46832:1;46822:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;46822:12:0;;46804:30;;46849:7;46844:70;46866:1;46862:5;;:1;:5;;;46844:70;;;46896:4;46901:1;46896:7;;;;;;;;;;;;46888:2;46891:1;46888:5;;;;;;;;;;;;;:15;;;;;;;;;;-1:-1:-1;46869:3:0;;46844:70;;7711:156;7785:7;7835:22;7839:3;7851:5;7835:3;:22::i;7018:165::-;7098:4;7121:55;7131:3;7151:23;;;7121:9;:55::i;38077:259::-;38142:4;;38158:150;38182:12;:19;38178:23;;38158:150;;;38245:7;38226:12;38239:1;38226:15;;;;;;;;;;;;;;;;:26;38222:76;;;38279:4;38272:11;;;;;38222:76;38203:3;;38158:150;;;-1:-1:-1;38324:5:0;;38077:259;-1:-1:-1;;38077:259:0:o;7264:115::-;7327:7;7353:19;7361:3;7353:7;:19::i;38623:974::-;38755:4;38771:16;;;:7;:16;;;;;;;;:25;;;;;;;:38;;;;;;;;;;38799:10;;38771:38;;;;;;;;;;:::i;:::-;-1:-1:-1;38771:38:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;38824:24;38840:7;38824:15;:24::i;:::-;38819:82;;38864:12;:26;;;;;;;-1:-1:-1;38864:26:0;;;;;;;;;38819:82;38911:25;38939:19;;;:10;:19;;;;;;38968:501;38992:16;;38988:20;;38968:501;;;39057:7;39033:9;39043:1;39033:12;;;;;;;;;;;;;;;;;;:20;;;:31;39029:430;;;39084:22;39109:9;39119:1;39109:12;;;;;;;;;;;;;;;;;;:25;;39084:50;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;39157:49;39172:10;:23;;;39197:8;39157:14;:49::i;:::-;39152:293;;39258:10;:23;;;39230:9;39240:1;39230:12;;;;;;;;;;;;;;;;;;:25;;:51;;;;;;;;;;;;:::i;:::-;;39336:13;39303:11;:20;39315:7;39303:20;;;;;;;;;;;39324:8;39303:30;;;;;;:::i;:::-;;;;;;;;;;;;;;;;:46;;;;39371:20;;;;:11;:20;;;39392:23;;;;39419:7;;39371:45;;39392:23;39371:45;:::i;:::-;;;;;;;;;;;;;;:55;39152:293;39029:430;;39010:3;;38968:501;;;-1:-1:-1;39478:26:0;;;;;;;;-1:-1:-1;39478:26:0;;;;;;;;;;;;;;;;;;;;;;;;39493:10;;39478:26;;;;;;;;;;:::i;:::-;-1:-1:-1;39478:26:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;39514:20;;;;;;;;;;39535:23;;;;39514:45;;39562:7;;39514:45;;;:::i;:::-;;;;;;;;;;;;;;:55;-1:-1:-1;39586:4:0;;-1:-1:-1;38623:974:0;;;;;:::o;1674:404::-;1737:4;1758:21;1768:3;1773:5;1758:9;:21::i;:::-;1753:319;;-1:-1:-1;1795:23:0;;;;;;;;:11;:23;;;;;;;;;;;;;1975:18;;1953:19;;;:12;;;:19;;;;;;:40;;;;2007:11;;1753:319;-1:-1:-1;2056:5:0;2049:12;;28779:215;28837:7;28860:6;28856:20;;-1:-1:-1;28875:1:0;28868:8;;28856:20;28898:5;;;28902:1;28898;:5;:1;28921:5;;;;;:10;28913:56;;;;;;;;;;;;:::i;29458:150::-;29516:7;29547:1;29543;:5;29535:44;;;;;;;;;;;;:::i;:::-;29600:1;29596;:5;;;;;;;29458:150;-1:-1:-1;;;29458:150:0:o;6781:156::-;6854:4;6877:53;6885:3;6905:23;;;6877:7;:53::i;48314:202::-;48361:8;48396:2;48385:8;;;;:13;48381:129;;;48431:1;48425:8;;48436:4;48425:15;48418:23;;48414:27;;48381:129;;;-1:-1:-1;48494:4:0;48483:8;;;;:15;48476:23;;;48314:202::o;47724:584::-;47963:14;;47946;;47799:13;;47853:2;;47895;;47799:13;;47946:31;47935:43;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;47935:43:0;-1:-1:-1;47909:69:0;-1:-1:-1;47909:69:0;48040:9;;48079:89;48095:7;:14;48091:1;:18;48079:89;;;48147:7;48155:1;48147:10;;;;;;;;;;;;;;;;48130:9;48140:3;;;;;;48130:14;;;;;;;;;;;:27;;;;;;;;;;-1:-1:-1;48111:3:0;;;;;48079:89;;;48187:1;48183:5;;48178:89;48194:7;:14;48190:1;:18;48178:89;;;48246:7;48254:1;48246:10;;;;;;;;;;;;;;;;48229:9;48239:3;;;;;;48229:14;;;;;;;;;;;:27;;;;;;;;;;-1:-1:-1;48210:3:0;;;;;48178:89;;;-1:-1:-1;48291:9:0;;47724:584;-1:-1:-1;;;;;;;47724:584:0:o;4486:201::-;4580:18;;4553:7;;4580:26;-1:-1:-1;4572:73:0;;;;;;;;;;;;:::i;:::-;4662:3;:11;;4674:5;4662:18;;;;;;;;;;;;;;;;4655:25;;4486:201;;;;:::o;3839:127::-;3912:4;3935:19;;;:12;;;;;:19;;;;;;:24;;;3839:127::o;4047:107::-;4129:18;;4047:107::o;48522:181::-;48603:4;48691:1;48673:21;;;;;;;;:::i;:::-;;;;;;;;;;;;;48663:32;;;;;;48655:1;48637:21;;;;;;;;:::i;:::-;;;;;;;;;;;;;48627:32;;;;;;:68;48619:77;;48522:181;;;;:::o;2246:1512::-;2312:4;2449:19;;;:12;;;:19;;;;;;2483:15;;2479:1273;;2912:18;;2864:14;;;;;2912:22;;;;2840:21;;2912:3;;:22;;3194;;;;;;;;;;;;;;3174:42;;3337:9;3308:3;:11;;3320:13;3308:26;;;;;;;;;;;;;;;;;;;:38;;;;3412:23;;;3454:1;3412:12;;;:23;;;;;;3438:17;;;3412:43;;3561:17;;3412:3;;3561:17;;;;;;;;;;;;;;;;;;;;;;3653:3;:12;;:19;3666:5;3653:19;;;;;;;;;;;3646:26;;;3694:4;3687:11;;;;;;;;2479:1273;3736:5;3729:12;;;;;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;5:130;72:20;;25657:42;25646:54;;26474:35;;26464:2;;26523:1;;26513:12;142:124;206:20;;25479:13;;25472:21;26595:32;;26585:2;;26641:1;;26631:12;425:337;;;540:3;533:4;525:6;521:17;517:27;507:2;;-1:-1;;548:12;507:2;-1:-1;578:20;;618:18;607:30;;604:2;;;-1:-1;;640:12;604:2;684:4;676:6;672:17;660:29;;735:3;684:4;715:17;676:6;701:32;;698:41;695:2;;;752:1;;742:12;695:2;500:262;;;;;:::o;771:442::-;;873:3;866:4;858:6;854:17;850:27;840:2;;-1:-1;;881:12;840:2;928:6;915:20;23869:18;;23861:6;23858:30;23855:2;;;-1:-1;;23891:12;23855:2;23524;23518:9;24032:4;23964:9;866:4;23949:6;23945:17;23941:33;23554:6;23550:17;;23661:6;23649:10;23646:22;23869:18;23613:10;23610:34;23607:62;23604:2;;;-1:-1;;23672:12;23604:2;23524;23691:22;1021:21;;;941:74;-1:-1;941:74;1121:16;;;24032:4;1121:16;1118:25;-1:-1;1115:2;;;1156:1;;1146:12;1115:2;25961:6;24032:4;1063:6;1059:17;24032:4;1097:5;1093:16;25938:30;26017:1;24032:4;26008:6;1097:5;25999:16;;25992:27;;;;833:380;;;;:::o;1358:126::-;1423:20;;25862:4;25851:16;;26962:33;;26952:2;;27009:1;;26999:12;1491:366;;;1612:2;1600:9;1591:7;1587:23;1583:32;1580:2;;;-1:-1;;1618:12;1580:2;1680:53;1725:7;1701:22;1680:53;:::i;:::-;1670:63;1770:2;1809:22;;;;1288:20;;-1:-1;;;1574:283::o;1864:611::-;;;;;2016:3;2004:9;1995:7;1991:23;1987:33;1984:2;;;-1:-1;;2023:12;1984:2;2085:53;2130:7;2106:22;2085:53;:::i;:::-;2075:63;;2175:2;2218:9;2214:22;1288:20;2183:63;;2301:53;2346:7;2283:2;2326:9;2322:22;2301:53;:::i;:::-;2291:63;;2391:2;2431:9;2427:22;206:20;26620:5;25479:13;25472:21;26598:5;26595:32;26585:2;;-1:-1;;26631:12;26585:2;1978:497;;;;-1:-1;1978:497;;-1:-1;;1978:497::o;2482:491::-;;;;2620:2;2608:9;2599:7;2595:23;2591:32;2588:2;;;-1:-1;;2626:12;2588:2;2688:53;2733:7;2709:22;2688:53;:::i;:::-;2678:63;2778:2;2817:22;;1288:20;;-1:-1;2886:2;2925:22;;;1288:20;;2582:391;-1:-1;;;2582:391::o;2980:241::-;;3084:2;3072:9;3063:7;3059:23;3055:32;3052:2;;;-1:-1;;3090:12;3052:2;-1:-1;340:20;;3046:175;-1:-1;3046:175::o;3228:366::-;;;3349:2;3337:9;3328:7;3324:23;3320:32;3317:2;;;-1:-1;;3355:12;3317:2;353:6;340:20;3407:63;;3507:2;3550:9;3546:22;72:20;25657:42;26502:5;25646:54;26477:5;26474:35;26464:2;;-1:-1;;26513:12;26464:2;3515:63;;;;3311:283;;;;;:::o;3601:366::-;;;3722:2;3710:9;3701:7;3697:23;3693:32;3690:2;;;-1:-1;;3728:12;3690:2;-1:-1;;340:20;;;3880:2;3919:22;;;1288:20;;-1:-1;3684:283::o;3974:1613::-;;;;;;;;;;;;;4262:3;4250:9;4241:7;4237:23;4233:33;4230:2;;;-1:-1;;4269:12;4230:2;4365:18;4327:17;4314:31;4354:30;4351:2;;;-1:-1;;4387:12;4351:2;4425:65;4482:7;4327:17;4314:31;4462:9;4458:22;4425:65;:::i;:::-;4407:83;;-1:-1;4407:83;-1:-1;4527:2;4566:22;;1288:20;;-1:-1;4653:53;4698:7;4635:2;4674:22;;4653:53;:::i;:::-;4643:63;;4761:51;4804:7;4743:2;4784:9;4780:22;4761:51;:::i;:::-;4751:61;;4849:3;4893:9;4889:22;1288:20;4858:63;;4958:3;5002:9;4998:22;1288:20;4967:63;;5067:3;5111:9;5107:22;1288:20;5076:63;;5176:3;5220:9;5216:22;1288:20;5185:63;;5285:3;5329:9;5325:22;1288:20;5294:63;;5414:50;5456:7;5394:3;5436:9;5432:22;5414:50;:::i;:::-;5403:61;;5521:50;5563:7;5501:3;5543:9;5539:22;5521:50;:::i;:::-;5510:61;;4224:1363;;;;;;;;;;;;;;:::o;5594:1719::-;;;;;;;;;;;;;5892:3;5880:9;5871:7;5867:23;5863:33;5860:2;;;-1:-1;;5899:12;5860:2;5995:18;5957:17;5944:31;5984:30;5981:2;;;-1:-1;;6017:12;5981:2;6055:65;6112:7;5957:17;5944:31;6092:9;6088:22;6055:65;:::i;:::-;6037:83;;-1:-1;6037:83;-1:-1;6157:2;6196:22;;1288:20;;-1:-1;5995:18;6293:2;6278:18;;6265:32;6306:30;6303:2;;;-1:-1;;6339:12;6303:2;6369:63;6424:7;6293:2;6282:9;6278:18;6265:32;6404:9;6400:22;6369:63;:::i;7320:347::-;;7434:2;7422:9;7413:7;7409:23;7405:32;7402:2;;;-1:-1;;7440:12;7402:2;7498:17;7485:31;7536:18;7528:6;7525:30;7522:2;;;-1:-1;;7558:12;7522:2;7588:63;7643:7;7634:6;7623:9;7619:22;7588:63;:::i;7674:472::-;;;7805:2;7793:9;7784:7;7780:23;7776:32;7773:2;;;-1:-1;;7811:12;7773:2;7869:17;7856:31;7907:18;7899:6;7896:30;7893:2;;;-1:-1;;7929:12;7893:2;7959:63;8014:7;8005:6;7994:9;7990:22;7959:63;:::i;:::-;7949:73;8059:2;8098:22;;;;1288:20;;-1:-1;;;;7767:379::o;8153:597::-;;;;8301:2;8289:9;8280:7;8276:23;8272:32;8269:2;;;-1:-1;;8307:12;8269:2;8365:17;8352:31;8403:18;8395:6;8392:30;8389:2;;;-1:-1;;8425:12;8389:2;8455:63;8510:7;8501:6;8490:9;8486:22;8455:63;:::i;:::-;8445:73;8555:2;8594:22;;1288:20;;-1:-1;8663:2;8702:22;;;1288:20;;8263:487;-1:-1;;;;8263:487::o;10775:94::-;25479:13;25472:21;10830:34;;10824:45::o;11107:327::-;;11242:5;24335:12;24771:6;24766:3;24759:19;11326:52;11371:6;24808:4;24803:3;24799:14;24808:4;11352:5;11348:16;11326:52;:::i;:::-;26398:2;26378:14;26394:7;26374:28;11390:39;;;;24808:4;11390:39;;11189:245;-1:-1;;11189:245::o;17790:97::-;25862:4;25851:16;17847:35;;17841:46::o;17894:275::-;;11958:5;24335:12;12070:52;12115:6;12110:3;12103:4;12096:5;12092:16;12070:52;:::i;:::-;12134:16;;;;;18030:139;-1:-1;;18030:139::o;18176:222::-;25657:42;25646:54;;;;9641:37;;18303:2;18288:18;;18274:124::o;18405:410::-;;18602:2;;18591:9;18587:18;18602:2;18623:17;18616:47;18677:128;10062:5;24335:12;24771:6;24766:3;24759:19;24799:14;18591:9;24799:14;10074:103;;24799:14;18602:2;10234:6;10230:17;18591:9;10221:27;;10209:39;;18602:2;10329:5;24179:14;-1:-1;10368:360;10393:6;10390:1;10387:13;10368:360;;;10445:20;18591:9;10449:4;10445:20;;10440:3;10433:33;9500:66;9562:3;10500:6;10494:13;9500:66;:::i;:::-;10514:92;-1:-1;10707:14;;;;24604;;;;10415:1;10408:9;10368:360;;;-1:-1;18669:136;;18573:242;-1:-1;;;;;;;18573:242::o;18822:210::-;25479:13;;25472:21;10830:34;;18943:2;18928:18;;18914:118::o;19039:222::-;11058:37;;;19166:2;19151:18;;19137:124::o;19268:310::-;;19415:2;19436:17;19429:47;19490:78;19415:2;19404:9;19400:18;19554:6;19490:78;:::i;19585:416::-;19785:2;19799:47;;;12387:2;19770:18;;;24759:19;12423:34;24799:14;;;12403:55;12492:4;12478:12;;;12471:26;12516:12;;;19756:245::o;20008:416::-;20208:2;20222:47;;;12767:2;20193:18;;;24759:19;12803:34;24799:14;;;12783:55;12872:17;12858:12;;;12851:39;12909:12;;;20179:245::o;20431:416::-;20631:2;20645:47;;;13160:2;20616:18;;;24759:19;13196:28;24799:14;;;13176:49;13244:12;;;20602:245::o;20854:416::-;21054:2;21068:47;;;13495:2;21039:18;;;24759:19;13531:34;24799:14;;;13511:55;13600:18;13586:12;;;13579:40;13638:12;;;21025:245::o;21277:416::-;21477:2;21491:47;;;13889:2;21462:18;;;24759:19;13925:34;24799:14;;;13905:55;13994:3;13980:12;;;13973:25;14017:12;;;21448:245::o;21700:416::-;21900:2;21914:47;;;14268:2;21885:18;;;24759:19;14304:30;24799:14;;;14284:51;14354:12;;;21871:245::o;22123:416::-;22323:2;22337:47;;;14605:2;22308:18;;;24759:19;14641:34;24799:14;;;14621:55;14710:17;14696:12;;;14689:39;14747:12;;;22294:245::o;22546:311::-;;22717:3;22706:9;22702:19;22694:27;;25657:42;;15053:16;15047:23;25646:54;9648:3;9641:37;15221:4;15214:5;15210:16;15204:23;15221:4;15285:3;15281:14;11058:37;25657:42;15382:4;15375:5;15371:16;15365:23;25646:54;15382:4;15446:3;15442:14;9641:37;;15540:4;15533:5;15529:16;15523:23;25479:13;25472:21;15540:4;15598:3;15594:14;10830:34;22688:169;;;;:::o;22864:362::-;;23037:2;23058:17;23051:47;15926:16;15920:23;23037:2;23026:9;23022:18;11058:37;23037:2;16092:5;16088:16;16082:23;15849:6;;16125:14;23026:9;16125:14;16118:38;16171:73;15840:16;23026:9;15840:16;16225:12;16171:73;:::i;:::-;16163:81;;16125:14;16331:5;16327:16;16321:23;16350:59;16394:14;23026:9;16394:14;16380:12;16350:59;:::i;:::-;;16394:14;16484:5;16480:16;16474:23;16551:14;23026:9;16551:14;11058:37;16551:14;16641:5;16637:16;16631:23;16708:14;23026:9;16708:14;11058:37;16708:14;16798:5;16794:16;16788:23;16865:14;23026:9;16865:14;11058:37;16865:14;16958:5;16954:16;16948:23;17025:14;23026:9;17025:14;11058:37;17025:14;17118:5;17114:16;17108:23;17185:14;17108:23;17185:14;23026:9;17185:14;11058:37;17185:14;17281:5;17277:18;17271:25;17251:45;;;17344:16;17302:59;17344:16;23026:9;17344:16;17330:12;17302:59;:::i;:::-;17437:18;;17431:25;;-1:-1;17462:59;17504:16;;;17431:25;17462:59;:::i;:::-;-1:-1;23104:112;;23008:218;-1:-1;;;;23008:218::o;26034:268::-;26099:1;26106:101;26120:6;26117:1;26114:13;26106:101;;;26187:11;;;26181:18;26168:11;;;26161:39;26142:2;26135:10;26106:101;;;26222:6;26219:1;26216:13;26213:2;;;26099:1;26278:6;26273:3;26269:16;26262:27;26213:2;;26083:219;;;:::o","abiDefinition":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"BRIDGEMANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeConfigVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"tokenAddress","type":"string"},{"internalType":"uint256","name":"chainID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateSwapFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"chainID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateSwapFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllTokenIDs","outputs":[{"internalType":"string[]","name":"result","type":"string[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainID","type":"uint256"}],"name":"getMaxGasPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"chainID","type":"uint256"}],"name":"getPoolConfig","outputs":[{"components":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"poolAddress","type":"address"},{"internalType":"bool","name":"metaswap","type":"bool"}],"internalType":"struct BridgeConfigV3.Pool","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"tokenID","type":"string"},{"internalType":"uint256","name":"chainID","type":"uint256"}],"name":"getToken","outputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"tokenAddress","type":"string"},{"internalType":"uint8","name":"tokenDecimals","type":"uint8"},{"internalType":"uint256","name":"maxSwap","type":"uint256"},{"internalType":"uint256","name":"minSwap","type":"uint256"},{"internalType":"uint256","name":"swapFee","type":"uint256"},{"internalType":"uint256","name":"maxSwapFee","type":"uint256"},{"internalType":"uint256","name":"minSwapFee","type":"uint256"},{"internalType":"bool","name":"hasUnderlying","type":"bool"},{"internalType":"bool","name":"isUnderlying","type":"bool"}],"internalType":"struct BridgeConfigV3.Token","name":"token","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"tokenAddress","type":"string"},{"internalType":"uint256","name":"chainID","type":"uint256"}],"name":"getTokenByAddress","outputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"tokenAddress","type":"string"},{"internalType":"uint8","name":"tokenDecimals","type":"uint8"},{"internalType":"uint256","name":"maxSwap","type":"uint256"},{"internalType":"uint256","name":"minSwap","type":"uint256"},{"internalType":"uint256","name":"swapFee","type":"uint256"},{"internalType":"uint256","name":"maxSwapFee","type":"uint256"},{"internalType":"uint256","name":"minSwapFee","type":"uint256"},{"internalType":"bool","name":"hasUnderlying","type":"bool"},{"internalType":"bool","name":"isUnderlying","type":"bool"}],"internalType":"struct BridgeConfigV3.Token","name":"token","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"chainID","type":"uint256"}],"name":"getTokenByEVMAddress","outputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"tokenAddress","type":"string"},{"internalType":"uint8","name":"tokenDecimals","type":"uint8"},{"internalType":"uint256","name":"maxSwap","type":"uint256"},{"internalType":"uint256","name":"minSwap","type":"uint256"},{"internalType":"uint256","name":"swapFee","type":"uint256"},{"internalType":"uint256","name":"maxSwapFee","type":"uint256"},{"internalType":"uint256","name":"minSwapFee","type":"uint256"},{"internalType":"bool","name":"hasUnderlying","type":"bool"},{"internalType":"bool","name":"isUnderlying","type":"bool"}],"internalType":"struct BridgeConfigV3.Token","name":"token","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"tokenID","type":"string"},{"internalType":"uint256","name":"chainID","type":"uint256"}],"name":"getTokenByID","outputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"tokenAddress","type":"string"},{"internalType":"uint8","name":"tokenDecimals","type":"uint8"},{"internalType":"uint256","name":"maxSwap","type":"uint256"},{"internalType":"uint256","name":"minSwap","type":"uint256"},{"internalType":"uint256","name":"swapFee","type":"uint256"},{"internalType":"uint256","name":"maxSwapFee","type":"uint256"},{"internalType":"uint256","name":"minSwapFee","type":"uint256"},{"internalType":"bool","name":"hasUnderlying","type":"bool"},{"internalType":"bool","name":"isUnderlying","type":"bool"}],"internalType":"struct BridgeConfigV3.Token","name":"token","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"chainID","type":"uint256"}],"name":"getTokenID","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"tokenAddress","type":"string"},{"internalType":"uint256","name":"chainID","type":"uint256"}],"name":"getTokenID","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"tokenID","type":"string"}],"name":"getUnderlyingToken","outputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"tokenAddress","type":"string"},{"internalType":"uint8","name":"tokenDecimals","type":"uint8"},{"internalType":"uint256","name":"maxSwap","type":"uint256"},{"internalType":"uint256","name":"minSwap","type":"uint256"},{"internalType":"uint256","name":"swapFee","type":"uint256"},{"internalType":"uint256","name":"maxSwapFee","type":"uint256"},{"internalType":"uint256","name":"minSwapFee","type":"uint256"},{"internalType":"bool","name":"hasUnderlying","type":"bool"},{"internalType":"bool","name":"isUnderlying","type":"bool"}],"internalType":"struct BridgeConfigV3.Token","name":"token","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"tokenID","type":"string"}],"name":"hasUnderlyingToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"tokenID","type":"string"}],"name":"isTokenIDExist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainID","type":"uint256"},{"internalType":"uint256","name":"maxPrice","type":"uint256"}],"name":"setMaxGasPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"chainID","type":"uint256"},{"internalType":"address","name":"poolAddress","type":"address"},{"internalType":"bool","name":"metaswap","type":"bool"}],"name":"setPoolConfig","outputs":[{"components":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"poolAddress","type":"address"},{"internalType":"bool","name":"metaswap","type":"bool"}],"internalType":"struct BridgeConfigV3.Pool","name":"","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"tokenID","type":"string"},{"internalType":"uint256","name":"chainID","type":"uint256"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"tokenDecimals","type":"uint8"},{"internalType":"uint256","name":"maxSwap","type":"uint256"},{"internalType":"uint256","name":"minSwap","type":"uint256"},{"internalType":"uint256","name":"swapFee","type":"uint256"},{"internalType":"uint256","name":"maxSwapFee","type":"uint256"},{"internalType":"uint256","name":"minSwapFee","type":"uint256"},{"internalType":"bool","name":"hasUnderlying","type":"bool"},{"internalType":"bool","name":"isUnderlying","type":"bool"}],"name":"setTokenConfig","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"tokenID","type":"string"},{"internalType":"uint256","name":"chainID","type":"uint256"},{"internalType":"string","name":"tokenAddress","type":"string"},{"internalType":"uint8","name":"tokenDecimals","type":"uint8"},{"internalType":"uint256","name":"maxSwap","type":"uint256"},{"internalType":"uint256","name":"minSwap","type":"uint256"},{"internalType":"uint256","name":"swapFee","type":"uint256"},{"internalType":"uint256","name":"maxSwapFee","type":"uint256"},{"internalType":"uint256","name":"minSwapFee","type":"uint256"},{"internalType":"bool","name":"hasUnderlying","type":"bool"},{"internalType":"bool","name":"isUnderlying","type":"bool"}],"name":"setTokenConfig","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"calculateSwapFee(address,uint256,uint256)":{"notice":"Calculates bridge swap fee based on the destination chain's token transfer."},"calculateSwapFee(string,uint256,uint256)":{"notice":"Calculates bridge swap fee based on the destination chain's token transfer."},"getAllTokenIDs()":{"notice":"Returns a list of all existing token IDs converted to strings"},"getMaxGasPrice(uint256)":{"notice":"gets the max gas price for a chain"},"getToken(string,uint256)":{"notice":"Returns the full token config struct"},"getTokenByAddress(string,uint256)":{"notice":"Returns token config struct, given an address and chainID"},"getTokenByID(string,uint256)":{"notice":"Returns the full token config struct"},"getTokenID(address,uint256)":{"notice":"Returns the token ID (string) of the cross-chain token inputted"},"getUnderlyingToken(string)":{"notice":"Returns which token is the underlying token to withdraw"},"hasUnderlyingToken(string)":{"notice":"Returns true if the token has an underlying token -- meaning the token is deposited into the bridge"},"isTokenIDExist(string)":{"notice":"Public function returning if token ID exists given a string"},"setMaxGasPrice(uint256,uint256)":{"notice":"sets the max gas price for a chain"},"setTokenConfig(string,uint256,address,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)":{"notice":"Main write function of this contract - Handles creating the struct and passing it to the internal logic function"},"setTokenConfig(string,uint256,string,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)":{"notice":"Main write function of this contract - Handles creating the struct and passing it to the internal logic function"}},"notice":"This token is used for configuring different tokens on the bridge and mapping them across chains.*","version":1},"developerDoc":{"kind":"dev","methods":{"calculateSwapFee(address,uint256,uint256)":{"details":"This means the fee should be calculated based on the chain that the nodes emit a tx on","params":{"amount":"in native token decimals","chainID":"destination chain ID to query the token config for","tokenAddress":"address of the destination token to query token config for"},"returns":{"_0":"Fee calculated in token decimals"}},"calculateSwapFee(string,uint256,uint256)":{"details":"This means the fee should be calculated based on the chain that the nodes emit a tx on","params":{"amount":"in native token decimals","chainID":"destination chain ID to query the token config for","tokenAddress":"address of the destination token to query token config for"},"returns":{"_0":"Fee calculated in token decimals"}},"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"getToken(string,uint256)":{"params":{"chainID":"Chain ID of which token address + config to get","tokenID":"String input of the token ID for the token"}},"getTokenByAddress(string,uint256)":{"params":{"chainID":"Chain ID of which token to get config for","tokenAddress":"Matches the token ID by using a combo of address + chain ID"}},"getTokenByID(string,uint256)":{"params":{"chainID":"Chain ID of which token address + config to get","tokenID":"String input of the token ID for the token"}},"getTokenID(address,uint256)":{"params":{"chainID":"chainID of which to get token ID for","tokenAddress":"address of token to get ID for"}},"getUnderlyingToken(string)":{"params":{"tokenID":"string token ID"}},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"hasUnderlyingToken(string)":{"params":{"tokenID":"String to check if it is a withdraw/underlying token"}},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role."},"setTokenConfig(string,uint256,address,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)":{"params":{"chainID":"chain ID to use for the token config object","hasUnderlying":"bool which represents whether this is a global mint token or one to withdraw()","isUnderlying":"bool which represents if this token is the one to withdraw on the given chain","maxSwap":"maximum amount of token allowed to be transferred at once - in native token decimals","maxSwapFee":"max swap fee to be charged - in native token decimals","minSwap":"minimum amount of token needed to be transferred at once - in native token decimals","minSwapFee":"min swap fee to be charged - in native token decimals - especially useful for mainnet ETH","swapFee":"percent based swap fee -- 10e6 == 10bps","tokenAddress":"token address of the token on the given chain","tokenDecimals":"decimals of token","tokenID":"string ID to set the token config object form"}},"setTokenConfig(string,uint256,string,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)":{"params":{"chainID":"chain ID to use for the token config object","hasUnderlying":"bool which represents whether this is a global mint token or one to withdraw()","isUnderlying":"bool which represents if this token is the one to withdraw on the given chain","maxSwap":"maximum amount of token allowed to be transferred at once - in native token decimals","maxSwapFee":"max swap fee to be charged - in native token decimals","minSwap":"minimum amount of token needed to be transferred at once - in native token decimals","minSwapFee":"min swap fee to be charged - in native token decimals - especially useful for mainnet ETH","swapFee":"percent based swap fee -- 10e6 == 10bps","tokenAddress":"token address of the token on the given chain","tokenDecimals":"decimals of token","tokenID":"string ID to set the token config object form"}}},"title":"BridgeConfig contract","version":1},"metadata":"{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BRIDGEMANAGER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridgeConfigVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenAddress\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"calculateSwapFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"calculateSwapFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllTokenIDs\",\"outputs\":[{\"internalType\":\"string[]\",\"name\":\"result\",\"type\":\"string[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"name\":\"getMaxGasPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"name\":\"getPoolConfig\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"metaswap\",\"type\":\"bool\"}],\"internalType\":\"struct BridgeConfigV3.Pool\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenID\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"name\":\"getToken\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"tokenAddress\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"tokenDecimals\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"maxSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"hasUnderlying\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isUnderlying\",\"type\":\"bool\"}],\"internalType\":\"struct BridgeConfigV3.Token\",\"name\":\"token\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenAddress\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"name\":\"getTokenByAddress\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"tokenAddress\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"tokenDecimals\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"maxSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"hasUnderlying\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isUnderlying\",\"type\":\"bool\"}],\"internalType\":\"struct BridgeConfigV3.Token\",\"name\":\"token\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"name\":\"getTokenByEVMAddress\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"tokenAddress\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"tokenDecimals\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"maxSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"hasUnderlying\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isUnderlying\",\"type\":\"bool\"}],\"internalType\":\"struct BridgeConfigV3.Token\",\"name\":\"token\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenID\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"name\":\"getTokenByID\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"tokenAddress\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"tokenDecimals\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"maxSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"hasUnderlying\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isUnderlying\",\"type\":\"bool\"}],\"internalType\":\"struct BridgeConfigV3.Token\",\"name\":\"token\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"name\":\"getTokenID\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenAddress\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"name\":\"getTokenID\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenID\",\"type\":\"string\"}],\"name\":\"getUnderlyingToken\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"tokenAddress\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"tokenDecimals\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"maxSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"hasUnderlying\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isUnderlying\",\"type\":\"bool\"}],\"internalType\":\"struct BridgeConfigV3.Token\",\"name\":\"token\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenID\",\"type\":\"string\"}],\"name\":\"hasUnderlyingToken\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenID\",\"type\":\"string\"}],\"name\":\"isTokenIDExist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxPrice\",\"type\":\"uint256\"}],\"name\":\"setMaxGasPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"metaswap\",\"type\":\"bool\"}],\"name\":\"setPoolConfig\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"metaswap\",\"type\":\"bool\"}],\"internalType\":\"struct BridgeConfigV3.Pool\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenID\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"tokenDecimals\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"maxSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"hasUnderlying\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isUnderlying\",\"type\":\"bool\"}],\"name\":\"setTokenConfig\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"tokenID\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"tokenAddress\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"tokenDecimals\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"maxSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minSwapFee\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"hasUnderlying\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isUnderlying\",\"type\":\"bool\"}],\"name\":\"setTokenConfig\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"calculateSwapFee(address,uint256,uint256)\":{\"details\":\"This means the fee should be calculated based on the chain that the nodes emit a tx on\",\"params\":{\"amount\":\"in native token decimals\",\"chainID\":\"destination chain ID to query the token config for\",\"tokenAddress\":\"address of the destination token to query token config for\"},\"returns\":{\"_0\":\"Fee calculated in token decimals\"}},\"calculateSwapFee(string,uint256,uint256)\":{\"details\":\"This means the fee should be calculated based on the chain that the nodes emit a tx on\",\"params\":{\"amount\":\"in native token decimals\",\"chainID\":\"destination chain ID to query the token config for\",\"tokenAddress\":\"address of the destination token to query token config for\"},\"returns\":{\"_0\":\"Fee calculated in token decimals\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"getToken(string,uint256)\":{\"params\":{\"chainID\":\"Chain ID of which token address + config to get\",\"tokenID\":\"String input of the token ID for the token\"}},\"getTokenByAddress(string,uint256)\":{\"params\":{\"chainID\":\"Chain ID of which token to get config for\",\"tokenAddress\":\"Matches the token ID by using a combo of address + chain ID\"}},\"getTokenByID(string,uint256)\":{\"params\":{\"chainID\":\"Chain ID of which token address + config to get\",\"tokenID\":\"String input of the token ID for the token\"}},\"getTokenID(address,uint256)\":{\"params\":{\"chainID\":\"chainID of which to get token ID for\",\"tokenAddress\":\"address of token to get ID for\"}},\"getUnderlyingToken(string)\":{\"params\":{\"tokenID\":\"string token ID\"}},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"hasUnderlyingToken(string)\":{\"params\":{\"tokenID\":\"String to check if it is a withdraw/underlying token\"}},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"},\"setTokenConfig(string,uint256,address,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)\":{\"params\":{\"chainID\":\"chain ID to use for the token config object\",\"hasUnderlying\":\"bool which represents whether this is a global mint token or one to withdraw()\",\"isUnderlying\":\"bool which represents if this token is the one to withdraw on the given chain\",\"maxSwap\":\"maximum amount of token allowed to be transferred at once - in native token decimals\",\"maxSwapFee\":\"max swap fee to be charged - in native token decimals\",\"minSwap\":\"minimum amount of token needed to be transferred at once - in native token decimals\",\"minSwapFee\":\"min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\",\"swapFee\":\"percent based swap fee -- 10e6 == 10bps\",\"tokenAddress\":\"token address of the token on the given chain\",\"tokenDecimals\":\"decimals of token\",\"tokenID\":\"string ID to set the token config object form\"}},\"setTokenConfig(string,uint256,string,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)\":{\"params\":{\"chainID\":\"chain ID to use for the token config object\",\"hasUnderlying\":\"bool which represents whether this is a global mint token or one to withdraw()\",\"isUnderlying\":\"bool which represents if this token is the one to withdraw on the given chain\",\"maxSwap\":\"maximum amount of token allowed to be transferred at once - in native token decimals\",\"maxSwapFee\":\"max swap fee to be charged - in native token decimals\",\"minSwap\":\"minimum amount of token needed to be transferred at once - in native token decimals\",\"minSwapFee\":\"min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\",\"swapFee\":\"percent based swap fee -- 10e6 == 10bps\",\"tokenAddress\":\"token address of the token on the given chain\",\"tokenDecimals\":\"decimals of token\",\"tokenID\":\"string ID to set the token config object form\"}}},\"title\":\"BridgeConfig contract\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"calculateSwapFee(address,uint256,uint256)\":{\"notice\":\"Calculates bridge swap fee based on the destination chain's token transfer.\"},\"calculateSwapFee(string,uint256,uint256)\":{\"notice\":\"Calculates bridge swap fee based on the destination chain's token transfer.\"},\"getAllTokenIDs()\":{\"notice\":\"Returns a list of all existing token IDs converted to strings\"},\"getMaxGasPrice(uint256)\":{\"notice\":\"gets the max gas price for a chain\"},\"getToken(string,uint256)\":{\"notice\":\"Returns the full token config struct\"},\"getTokenByAddress(string,uint256)\":{\"notice\":\"Returns token config struct, given an address and chainID\"},\"getTokenByID(string,uint256)\":{\"notice\":\"Returns the full token config struct\"},\"getTokenID(address,uint256)\":{\"notice\":\"Returns the token ID (string) of the cross-chain token inputted\"},\"getUnderlyingToken(string)\":{\"notice\":\"Returns which token is the underlying token to withdraw\"},\"hasUnderlyingToken(string)\":{\"notice\":\"Returns true if the token has an underlying token -- meaning the token is deposited into the bridge\"},\"isTokenIDExist(string)\":{\"notice\":\"Public function returning if token ID exists given a string\"},\"setMaxGasPrice(uint256,uint256)\":{\"notice\":\"sets the max gas price for a chain\"},\"setTokenConfig(string,uint256,address,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)\":{\"notice\":\"Main write function of this contract - Handles creating the struct and passing it to the internal logic function\"},\"setTokenConfig(string,uint256,string,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)\":{\"notice\":\"Main write function of this contract - Handles creating the struct and passing it to the internal logic function\"}},\"notice\":\"This token is used for configuring different tokens on the bridge and mapping them across chains.*\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"/solidity/BridgeConfigV3_flat.sol\":\"BridgeConfigV3\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/solidity/BridgeConfigV3_flat.sol\":{\"keccak256\":\"0xed97c5e2e62a33d867264cf25c64f2215222ad36723fee31796bfd0930a0fffd\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ed38243be38158798b1de0aaa7ba9a22df5f9bca3a1ff9ba814719c9e0391e26\",\"dweb:/ipfs/Qmebz2oFzXzZdE27FNbhhYbvVsDXKPy9pYrBxEVXQDaC4X\"]}},\"version\":1}"},"hashes":{"BRIDGEMANAGER_ROLE()":"ff9106c7","DEFAULT_ADMIN_ROLE()":"a217fddf","bridgeConfigVersion()":"2c02799e","calculateSwapFee(address,uint256,uint256)":"fc7cc4cb","calculateSwapFee(string,uint256,uint256)":"0a62a9cb","getAllTokenIDs()":"684a10b3","getMaxGasPrice(uint256)":"fd534b33","getPoolConfig(address,uint256)":"72fb43d9","getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","getToken(string,uint256)":"324980b5","getTokenByAddress(string,uint256)":"e814157d","getTokenByEVMAddress(address,uint256)":"558dae3a","getTokenByID(string,uint256)":"77b8cbf7","getTokenID(address,uint256)":"3cc1c7e0","getTokenID(string,uint256)":"efd7516e","getUnderlyingToken(string)":"58dfe6f1","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","hasUnderlyingToken(string)":"074b7e97","isTokenIDExist(string)":"af611ca0","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","setMaxGasPrice(uint256,uint256)":"abaac008","setPoolConfig(address,uint256,address,bool)":"7e355e5e","setTokenConfig(string,uint256,address,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)":"59053bfe","setTokenConfig(string,uint256,string,uint8,uint256,uint256,uint256,uint256,uint256,bool,bool)":"ddb54399"}},"/solidity/BridgeConfigV3_flat.sol:Context":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\n\n\n\n\n\n\n\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping (bytes32 =\u003e uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) { // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n require(set._values.length \u003e index, \"EnumerableSet: index out of bounds\");\n return set._values[index];\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n}\n\n\n\n\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\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 // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size \u003e 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 \u003e= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\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(address target, bytes memory data, string memory errorMessage) 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(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\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(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\n\n\n\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\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 AccessControl is Context {\n using EnumerableSet for EnumerableSet.AddressSet;\n using Address for address;\n\n struct RoleData {\n EnumerableSet.AddressSet members;\n bytes32 adminRole;\n }\n\n mapping (bytes32 =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\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 {_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) public view returns (bool) {\n return _roles[role].members.contains(account);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n return _roles[role].members.length();\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n return _roles[role].members.at(index);\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 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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\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 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) public virtual {\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 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 emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\n _roles[role].adminRole = adminRole;\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (_roles[role].members.add(account)) {\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (_roles[role].members.remove(account)) {\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n\n\n\n\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c \u003c a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b \u003e a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c \u003e= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003c= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003c= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a % b;\n }\n}\n\n\n/**\n * @title BridgeConfig contract\n * @notice This token is used for configuring different tokens on the bridge and mapping them across chains.\n **/\n\ncontract BridgeConfigV3 is AccessControl {\n using SafeMath for uint256;\n bytes32 public constant BRIDGEMANAGER_ROLE = keccak256(\"BRIDGEMANAGER_ROLE\");\n bytes32[] private _allTokenIDs;\n mapping(bytes32 =\u003e Token[]) private _allTokens; // key is tokenID\n mapping(uint256 =\u003e mapping(string =\u003e bytes32)) private _tokenIDMap; // key is chainID,tokenAddress\n mapping(bytes32 =\u003e mapping(uint256 =\u003e Token)) private _tokens; // key is tokenID,chainID\n mapping(address =\u003e mapping(uint256 =\u003e Pool)) private _pool; // key is tokenAddress,chainID\n mapping(uint256 =\u003e uint256) private _maxGasPrice; // key is tokenID,chainID\n uint256 public constant bridgeConfigVersion = 3;\n\n // the denominator used to calculate fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // this struct must be initialized using setTokenConfig for each token that directly interacts with the bridge\n struct Token {\n uint256 chainId;\n string tokenAddress;\n uint8 tokenDecimals;\n uint256 maxSwap;\n uint256 minSwap;\n uint256 swapFee;\n uint256 maxSwapFee;\n uint256 minSwapFee;\n bool hasUnderlying;\n bool isUnderlying;\n }\n\n struct Pool {\n address tokenAddress;\n uint256 chainId;\n address poolAddress;\n bool metaswap;\n }\n\n constructor() public {\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n }\n\n /**\n * @notice Returns a list of all existing token IDs converted to strings\n */\n function getAllTokenIDs() public view returns (string[] memory result) {\n uint256 length = _allTokenIDs.length;\n result = new string[](length);\n for (uint256 i = 0; i \u003c length; ++i) {\n result[i] = toString(_allTokenIDs[i]);\n }\n }\n\n function _getTokenID(string memory tokenAddress, uint256 chainID) internal view returns (string memory) {\n return toString(_tokenIDMap[chainID][tokenAddress]);\n }\n\n function getTokenID(string memory tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(tokenAddress), chainID);\n }\n\n /**\n * @notice Returns the token ID (string) of the cross-chain token inputted\n * @param tokenAddress address of token to get ID for\n * @param chainID chainID of which to get token ID for\n */\n function getTokenID(address tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(toString(tokenAddress)), chainID);\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getToken(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getTokenByID(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns token config struct, given an address and chainID\n * @param tokenAddress Matches the token ID by using a combo of address + chain ID\n * @param chainID Chain ID of which token to get config for\n */\n function getTokenByAddress(string memory tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(tokenAddress)]][chainID];\n }\n\n function getTokenByEVMAddress(address tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(toString(tokenAddress))]][chainID];\n }\n\n /**\n * @notice Returns true if the token has an underlying token -- meaning the token is deposited into the bridge\n * @param tokenID String to check if it is a withdraw/underlying token\n */\n function hasUnderlyingToken(string memory tokenID) public view returns (bool) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].hasUnderlying) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Returns which token is the underlying token to withdraw\n * @param tokenID string token ID\n */\n function getUnderlyingToken(string memory tokenID) public view returns (Token memory token) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].isUnderlying) {\n return _mcTokens[i];\n }\n }\n }\n\n /**\n @notice Public function returning if token ID exists given a string\n */\n function isTokenIDExist(string memory tokenID) public view returns (bool) {\n return _isTokenIDExist(toBytes32(tokenID));\n }\n\n /**\n @notice Internal function returning if token ID exists given bytes32 version of the ID\n */\n function _isTokenIDExist(bytes32 tokenID) internal view returns (bool) {\n for (uint256 i = 0; i \u003c _allTokenIDs.length; ++i) {\n if (_allTokenIDs[i] == tokenID) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Internal function which handles logic of setting token ID and dealing with mappings\n * @param tokenID bytes32 version of ID\n * @param chainID which chain to set the token config for\n * @param tokenToAdd Token object to set the mapping to\n */\n function _setTokenConfig(\n bytes32 tokenID,\n uint256 chainID,\n Token memory tokenToAdd\n ) internal returns (bool) {\n _tokens[tokenID][chainID] = tokenToAdd;\n if (!_isTokenIDExist(tokenID)) {\n _allTokenIDs.push(tokenID);\n }\n\n Token[] storage _mcTokens = _allTokens[tokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].chainId == chainID) {\n string memory oldToken = _mcTokens[i].tokenAddress;\n if (!compareStrings(tokenToAdd.tokenAddress, oldToken)) {\n _mcTokens[i].tokenAddress = tokenToAdd.tokenAddress;\n _tokenIDMap[chainID][oldToken] = keccak256(\"\");\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n }\n }\n }\n _mcTokens.push(tokenToAdd);\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n return true;\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n address tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n return\n setTokenConfig(\n tokenID,\n chainID,\n toString(tokenAddress),\n tokenDecimals,\n maxSwap,\n minSwap,\n swapFee,\n maxSwapFee,\n minSwapFee,\n hasUnderlying,\n isUnderlying\n );\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n string memory tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n Token memory tokenToAdd;\n tokenToAdd.tokenAddress = _toLower(tokenAddress);\n tokenToAdd.tokenDecimals = tokenDecimals;\n tokenToAdd.maxSwap = maxSwap;\n tokenToAdd.minSwap = minSwap;\n tokenToAdd.swapFee = swapFee;\n tokenToAdd.maxSwapFee = maxSwapFee;\n tokenToAdd.minSwapFee = minSwapFee;\n tokenToAdd.hasUnderlying = hasUnderlying;\n tokenToAdd.isUnderlying = isUnderlying;\n tokenToAdd.chainId = chainID;\n\n return _setTokenConfig(toBytes32(tokenID), chainID, tokenToAdd);\n }\n\n function _calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) internal view returns (uint256) {\n Token memory token = _tokens[_tokenIDMap[chainID][tokenAddress]][chainID];\n uint256 calculatedSwapFee = amount.mul(token.swapFee).div(FEE_DENOMINATOR);\n if (calculatedSwapFee \u003e token.minSwapFee \u0026\u0026 calculatedSwapFee \u003c token.maxSwapFee) {\n return calculatedSwapFee;\n } else if (calculatedSwapFee \u003e token.maxSwapFee) {\n return token.maxSwapFee;\n } else {\n return token.minSwapFee;\n }\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(tokenAddress), chainID, amount);\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n address tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(toString(tokenAddress)), chainID, amount);\n }\n\n // GAS PRICING\n\n /**\n * @notice sets the max gas price for a chain\n */\n function setMaxGasPrice(uint256 chainID, uint256 maxPrice) public {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n _maxGasPrice[chainID] = maxPrice;\n }\n\n /**\n * @notice gets the max gas price for a chain\n */\n function getMaxGasPrice(uint256 chainID) public view returns (uint256) {\n return _maxGasPrice[chainID];\n }\n\n // POOL CONFIG\n\n function getPoolConfig(address tokenAddress, uint256 chainID) external view returns (Pool memory) {\n return _pool[tokenAddress][chainID];\n }\n\n function setPoolConfig(\n address tokenAddress,\n uint256 chainID,\n address poolAddress,\n bool metaswap\n ) external returns (Pool memory) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender), \"Caller is not Bridge Manager\");\n Pool memory newPool = Pool(tokenAddress, chainID, poolAddress, metaswap);\n _pool[tokenAddress][chainID] = newPool;\n return newPool;\n }\n\n // UTILITY FUNCTIONS\n\n function toString(bytes32 data) internal pure returns (string memory) {\n uint8 i = 0;\n while (i \u003c 32 \u0026\u0026 data[i] != 0) {\n ++i;\n }\n bytes memory bs = new bytes(i);\n for (uint8 j = 0; j \u003c i; ++j) {\n bs[j] = data[j];\n }\n return string(bs);\n }\n\n // toBytes32 converts a string to a bytes 32\n function toBytes32(string memory str) internal pure returns (bytes32 result) {\n require(bytes(str).length \u003c= 32);\n assembly {\n result := mload(add(str, 32))\n }\n }\n\n function toString(address x) internal pure returns (string memory) {\n bytes memory s = new bytes(40);\n for (uint256 i = 0; i \u003c 20; i++) {\n bytes1 b = bytes1(uint8(uint256(uint160(x)) / (2**(8 * (19 - i)))));\n bytes1 hi = bytes1(uint8(b) / 16);\n bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));\n s[2 * i] = char(hi);\n s[2 * i + 1] = char(lo);\n }\n\n string memory addrPrefix = \"0x\";\n\n return concat(addrPrefix, string(s));\n }\n\n function concat(string memory _x, string memory _y) internal pure returns (string memory) {\n bytes memory _xBytes = bytes(_x);\n bytes memory _yBytes = bytes(_y);\n\n string memory _tmpValue = new string(_xBytes.length + _yBytes.length);\n bytes memory _newValue = bytes(_tmpValue);\n\n uint256 i;\n uint256 j;\n\n for (i = 0; i \u003c _xBytes.length; i++) {\n _newValue[j++] = _xBytes[i];\n }\n\n for (i = 0; i \u003c _yBytes.length; i++) {\n _newValue[j++] = _yBytes[i];\n }\n\n return string(_newValue);\n }\n\n function char(bytes1 b) internal pure returns (bytes1 c) {\n if (uint8(b) \u003c 10) {\n c = bytes1(uint8(b) + 0x30);\n } else {\n c = bytes1(uint8(b) + 0x57);\n }\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function _toLower(string memory str) internal pure returns (string memory) {\n bytes memory bStr = bytes(str);\n bytes memory bLower = new bytes(bStr.length);\n for (uint256 i = 0; i \u003c bStr.length; i++) {\n // Uppercase character...\n if ((uint8(bStr[i]) \u003e= 65) \u0026\u0026 (uint8(bStr[i]) \u003c= 90)) {\n // So we add 32 to make it lowercase\n bLower[i] = bytes1(uint8(bStr[i]) + 32);\n } else {\n bLower[i] = bStr[i];\n }\n }\n return string(bLower);\n }\n}\n\n\n\n","language":"Solidity","languageVersion":"0.6.12","compilerVersion":"0.6.12","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/solidity/BridgeConfigV3_flat.sol\":\"Context\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/solidity/BridgeConfigV3_flat.sol\":{\"keccak256\":\"0xed97c5e2e62a33d867264cf25c64f2215222ad36723fee31796bfd0930a0fffd\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ed38243be38158798b1de0aaa7ba9a22df5f9bca3a1ff9ba814719c9e0391e26\",\"dweb:/ipfs/Qmebz2oFzXzZdE27FNbhhYbvVsDXKPy9pYrBxEVXQDaC4X\"]}},\"version\":1}"},"hashes":{}},"/solidity/BridgeConfigV3_flat.sol:EnumerableSet":{"code":"0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220405e2324b796616fb7f971f7b3275378e9fe83959e1a656abdd6c0338eca2e6f64736f6c634300060c0033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220405e2324b796616fb7f971f7b3275378e9fe83959e1a656abdd6c0338eca2e6f64736f6c634300060c0033","info":{"source":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\n\n\n\n\n\n\n\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping (bytes32 =\u003e uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) { // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n require(set._values.length \u003e index, \"EnumerableSet: index out of bounds\");\n return set._values[index];\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n}\n\n\n\n\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\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 // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size \u003e 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 \u003e= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\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(address target, bytes memory data, string memory errorMessage) 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(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\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(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\n\n\n\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\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 AccessControl is Context {\n using EnumerableSet for EnumerableSet.AddressSet;\n using Address for address;\n\n struct RoleData {\n EnumerableSet.AddressSet members;\n bytes32 adminRole;\n }\n\n mapping (bytes32 =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\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 {_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) public view returns (bool) {\n return _roles[role].members.contains(account);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n return _roles[role].members.length();\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n return _roles[role].members.at(index);\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 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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\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 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) public virtual {\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 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 emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\n _roles[role].adminRole = adminRole;\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (_roles[role].members.add(account)) {\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (_roles[role].members.remove(account)) {\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n\n\n\n\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c \u003c a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b \u003e a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c \u003e= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003c= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003c= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a % b;\n }\n}\n\n\n/**\n * @title BridgeConfig contract\n * @notice This token is used for configuring different tokens on the bridge and mapping them across chains.\n **/\n\ncontract BridgeConfigV3 is AccessControl {\n using SafeMath for uint256;\n bytes32 public constant BRIDGEMANAGER_ROLE = keccak256(\"BRIDGEMANAGER_ROLE\");\n bytes32[] private _allTokenIDs;\n mapping(bytes32 =\u003e Token[]) private _allTokens; // key is tokenID\n mapping(uint256 =\u003e mapping(string =\u003e bytes32)) private _tokenIDMap; // key is chainID,tokenAddress\n mapping(bytes32 =\u003e mapping(uint256 =\u003e Token)) private _tokens; // key is tokenID,chainID\n mapping(address =\u003e mapping(uint256 =\u003e Pool)) private _pool; // key is tokenAddress,chainID\n mapping(uint256 =\u003e uint256) private _maxGasPrice; // key is tokenID,chainID\n uint256 public constant bridgeConfigVersion = 3;\n\n // the denominator used to calculate fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // this struct must be initialized using setTokenConfig for each token that directly interacts with the bridge\n struct Token {\n uint256 chainId;\n string tokenAddress;\n uint8 tokenDecimals;\n uint256 maxSwap;\n uint256 minSwap;\n uint256 swapFee;\n uint256 maxSwapFee;\n uint256 minSwapFee;\n bool hasUnderlying;\n bool isUnderlying;\n }\n\n struct Pool {\n address tokenAddress;\n uint256 chainId;\n address poolAddress;\n bool metaswap;\n }\n\n constructor() public {\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n }\n\n /**\n * @notice Returns a list of all existing token IDs converted to strings\n */\n function getAllTokenIDs() public view returns (string[] memory result) {\n uint256 length = _allTokenIDs.length;\n result = new string[](length);\n for (uint256 i = 0; i \u003c length; ++i) {\n result[i] = toString(_allTokenIDs[i]);\n }\n }\n\n function _getTokenID(string memory tokenAddress, uint256 chainID) internal view returns (string memory) {\n return toString(_tokenIDMap[chainID][tokenAddress]);\n }\n\n function getTokenID(string memory tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(tokenAddress), chainID);\n }\n\n /**\n * @notice Returns the token ID (string) of the cross-chain token inputted\n * @param tokenAddress address of token to get ID for\n * @param chainID chainID of which to get token ID for\n */\n function getTokenID(address tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(toString(tokenAddress)), chainID);\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getToken(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getTokenByID(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns token config struct, given an address and chainID\n * @param tokenAddress Matches the token ID by using a combo of address + chain ID\n * @param chainID Chain ID of which token to get config for\n */\n function getTokenByAddress(string memory tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(tokenAddress)]][chainID];\n }\n\n function getTokenByEVMAddress(address tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(toString(tokenAddress))]][chainID];\n }\n\n /**\n * @notice Returns true if the token has an underlying token -- meaning the token is deposited into the bridge\n * @param tokenID String to check if it is a withdraw/underlying token\n */\n function hasUnderlyingToken(string memory tokenID) public view returns (bool) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].hasUnderlying) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Returns which token is the underlying token to withdraw\n * @param tokenID string token ID\n */\n function getUnderlyingToken(string memory tokenID) public view returns (Token memory token) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].isUnderlying) {\n return _mcTokens[i];\n }\n }\n }\n\n /**\n @notice Public function returning if token ID exists given a string\n */\n function isTokenIDExist(string memory tokenID) public view returns (bool) {\n return _isTokenIDExist(toBytes32(tokenID));\n }\n\n /**\n @notice Internal function returning if token ID exists given bytes32 version of the ID\n */\n function _isTokenIDExist(bytes32 tokenID) internal view returns (bool) {\n for (uint256 i = 0; i \u003c _allTokenIDs.length; ++i) {\n if (_allTokenIDs[i] == tokenID) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Internal function which handles logic of setting token ID and dealing with mappings\n * @param tokenID bytes32 version of ID\n * @param chainID which chain to set the token config for\n * @param tokenToAdd Token object to set the mapping to\n */\n function _setTokenConfig(\n bytes32 tokenID,\n uint256 chainID,\n Token memory tokenToAdd\n ) internal returns (bool) {\n _tokens[tokenID][chainID] = tokenToAdd;\n if (!_isTokenIDExist(tokenID)) {\n _allTokenIDs.push(tokenID);\n }\n\n Token[] storage _mcTokens = _allTokens[tokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].chainId == chainID) {\n string memory oldToken = _mcTokens[i].tokenAddress;\n if (!compareStrings(tokenToAdd.tokenAddress, oldToken)) {\n _mcTokens[i].tokenAddress = tokenToAdd.tokenAddress;\n _tokenIDMap[chainID][oldToken] = keccak256(\"\");\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n }\n }\n }\n _mcTokens.push(tokenToAdd);\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n return true;\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n address tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n return\n setTokenConfig(\n tokenID,\n chainID,\n toString(tokenAddress),\n tokenDecimals,\n maxSwap,\n minSwap,\n swapFee,\n maxSwapFee,\n minSwapFee,\n hasUnderlying,\n isUnderlying\n );\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n string memory tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n Token memory tokenToAdd;\n tokenToAdd.tokenAddress = _toLower(tokenAddress);\n tokenToAdd.tokenDecimals = tokenDecimals;\n tokenToAdd.maxSwap = maxSwap;\n tokenToAdd.minSwap = minSwap;\n tokenToAdd.swapFee = swapFee;\n tokenToAdd.maxSwapFee = maxSwapFee;\n tokenToAdd.minSwapFee = minSwapFee;\n tokenToAdd.hasUnderlying = hasUnderlying;\n tokenToAdd.isUnderlying = isUnderlying;\n tokenToAdd.chainId = chainID;\n\n return _setTokenConfig(toBytes32(tokenID), chainID, tokenToAdd);\n }\n\n function _calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) internal view returns (uint256) {\n Token memory token = _tokens[_tokenIDMap[chainID][tokenAddress]][chainID];\n uint256 calculatedSwapFee = amount.mul(token.swapFee).div(FEE_DENOMINATOR);\n if (calculatedSwapFee \u003e token.minSwapFee \u0026\u0026 calculatedSwapFee \u003c token.maxSwapFee) {\n return calculatedSwapFee;\n } else if (calculatedSwapFee \u003e token.maxSwapFee) {\n return token.maxSwapFee;\n } else {\n return token.minSwapFee;\n }\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(tokenAddress), chainID, amount);\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n address tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(toString(tokenAddress)), chainID, amount);\n }\n\n // GAS PRICING\n\n /**\n * @notice sets the max gas price for a chain\n */\n function setMaxGasPrice(uint256 chainID, uint256 maxPrice) public {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n _maxGasPrice[chainID] = maxPrice;\n }\n\n /**\n * @notice gets the max gas price for a chain\n */\n function getMaxGasPrice(uint256 chainID) public view returns (uint256) {\n return _maxGasPrice[chainID];\n }\n\n // POOL CONFIG\n\n function getPoolConfig(address tokenAddress, uint256 chainID) external view returns (Pool memory) {\n return _pool[tokenAddress][chainID];\n }\n\n function setPoolConfig(\n address tokenAddress,\n uint256 chainID,\n address poolAddress,\n bool metaswap\n ) external returns (Pool memory) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender), \"Caller is not Bridge Manager\");\n Pool memory newPool = Pool(tokenAddress, chainID, poolAddress, metaswap);\n _pool[tokenAddress][chainID] = newPool;\n return newPool;\n }\n\n // UTILITY FUNCTIONS\n\n function toString(bytes32 data) internal pure returns (string memory) {\n uint8 i = 0;\n while (i \u003c 32 \u0026\u0026 data[i] != 0) {\n ++i;\n }\n bytes memory bs = new bytes(i);\n for (uint8 j = 0; j \u003c i; ++j) {\n bs[j] = data[j];\n }\n return string(bs);\n }\n\n // toBytes32 converts a string to a bytes 32\n function toBytes32(string memory str) internal pure returns (bytes32 result) {\n require(bytes(str).length \u003c= 32);\n assembly {\n result := mload(add(str, 32))\n }\n }\n\n function toString(address x) internal pure returns (string memory) {\n bytes memory s = new bytes(40);\n for (uint256 i = 0; i \u003c 20; i++) {\n bytes1 b = bytes1(uint8(uint256(uint160(x)) / (2**(8 * (19 - i)))));\n bytes1 hi = bytes1(uint8(b) / 16);\n bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));\n s[2 * i] = char(hi);\n s[2 * i + 1] = char(lo);\n }\n\n string memory addrPrefix = \"0x\";\n\n return concat(addrPrefix, string(s));\n }\n\n function concat(string memory _x, string memory _y) internal pure returns (string memory) {\n bytes memory _xBytes = bytes(_x);\n bytes memory _yBytes = bytes(_y);\n\n string memory _tmpValue = new string(_xBytes.length + _yBytes.length);\n bytes memory _newValue = bytes(_tmpValue);\n\n uint256 i;\n uint256 j;\n\n for (i = 0; i \u003c _xBytes.length; i++) {\n _newValue[j++] = _xBytes[i];\n }\n\n for (i = 0; i \u003c _yBytes.length; i++) {\n _newValue[j++] = _yBytes[i];\n }\n\n return string(_newValue);\n }\n\n function char(bytes1 b) internal pure returns (bytes1 c) {\n if (uint8(b) \u003c 10) {\n c = bytes1(uint8(b) + 0x30);\n } else {\n c = bytes1(uint8(b) + 0x57);\n }\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function _toLower(string memory str) internal pure returns (string memory) {\n bytes memory bStr = bytes(str);\n bytes memory bLower = new bytes(bStr.length);\n for (uint256 i = 0; i \u003c bStr.length; i++) {\n // Uppercase character...\n if ((uint8(bStr[i]) \u003e= 65) \u0026\u0026 (uint8(bStr[i]) \u003c= 90)) {\n // So we add 32 to make it lowercase\n bLower[i] = bytes1(uint8(bStr[i]) + 32);\n } else {\n bLower[i] = bStr[i];\n }\n }\n return string(bLower);\n }\n}\n\n\n\n","language":"Solidity","languageVersion":"0.6.12","compilerVersion":"0.6.12","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"787:8634:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;","srcMapRuntime":"787:8634:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Library for managing https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive types. Sets have the following properties: - Elements are added, removed, and checked for existence in constant time (O(1)). - Elements are enumerated in O(n). No guarantees are made on the ordering. ``` contract Example { // Add the library methods using EnumerableSet for EnumerableSet.AddressSet; // Declare a set state variable EnumerableSet.AddressSet private mySet; } ``` As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) and `uint256` (`UintSet`) are supported.","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Library for managing https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive types. Sets have the following properties: - Elements are added, removed, and checked for existence in constant time (O(1)). - Elements are enumerated in O(n). No guarantees are made on the ordering. ``` contract Example { // Add the library methods using EnumerableSet for EnumerableSet.AddressSet; // Declare a set state variable EnumerableSet.AddressSet private mySet; } ``` As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) and `uint256` (`UintSet`) are supported.\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/solidity/BridgeConfigV3_flat.sol\":\"EnumerableSet\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/solidity/BridgeConfigV3_flat.sol\":{\"keccak256\":\"0xed97c5e2e62a33d867264cf25c64f2215222ad36723fee31796bfd0930a0fffd\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ed38243be38158798b1de0aaa7ba9a22df5f9bca3a1ff9ba814719c9e0391e26\",\"dweb:/ipfs/Qmebz2oFzXzZdE27FNbhhYbvVsDXKPy9pYrBxEVXQDaC4X\"]}},\"version\":1}"},"hashes":{}},"/solidity/BridgeConfigV3_flat.sol:SafeMath":{"code":"0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d4eddff4055697d351f5a3da789f263dfbf77e5fafc13033c5bee8f2fc527b9964736f6c634300060c0033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d4eddff4055697d351f5a3da789f263dfbf77e5fafc13033c5bee8f2fc527b9964736f6c634300060c0033","info":{"source":"// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\n\n\n\n\n\n\n\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping (bytes32 =\u003e uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) { // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n require(set._values.length \u003e index, \"EnumerableSet: index out of bounds\");\n return set._values[index];\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n}\n\n\n\n\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\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 // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size \u003e 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 \u003e= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\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(address target, bytes memory data, string memory errorMessage) 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(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\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(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\n\n\n\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\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 AccessControl is Context {\n using EnumerableSet for EnumerableSet.AddressSet;\n using Address for address;\n\n struct RoleData {\n EnumerableSet.AddressSet members;\n bytes32 adminRole;\n }\n\n mapping (bytes32 =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\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 {_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) public view returns (bool) {\n return _roles[role].members.contains(account);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n return _roles[role].members.length();\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n return _roles[role].members.at(index);\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 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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\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 {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\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 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) public virtual {\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 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 emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\n _roles[role].adminRole = adminRole;\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (_roles[role].members.add(account)) {\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (_roles[role].members.remove(account)) {\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n\n\n\n\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c \u003c a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b \u003e a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c \u003e= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003c= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003e 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003c= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b \u003e 0, errorMessage);\n return a % b;\n }\n}\n\n\n/**\n * @title BridgeConfig contract\n * @notice This token is used for configuring different tokens on the bridge and mapping them across chains.\n **/\n\ncontract BridgeConfigV3 is AccessControl {\n using SafeMath for uint256;\n bytes32 public constant BRIDGEMANAGER_ROLE = keccak256(\"BRIDGEMANAGER_ROLE\");\n bytes32[] private _allTokenIDs;\n mapping(bytes32 =\u003e Token[]) private _allTokens; // key is tokenID\n mapping(uint256 =\u003e mapping(string =\u003e bytes32)) private _tokenIDMap; // key is chainID,tokenAddress\n mapping(bytes32 =\u003e mapping(uint256 =\u003e Token)) private _tokens; // key is tokenID,chainID\n mapping(address =\u003e mapping(uint256 =\u003e Pool)) private _pool; // key is tokenAddress,chainID\n mapping(uint256 =\u003e uint256) private _maxGasPrice; // key is tokenID,chainID\n uint256 public constant bridgeConfigVersion = 3;\n\n // the denominator used to calculate fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // this struct must be initialized using setTokenConfig for each token that directly interacts with the bridge\n struct Token {\n uint256 chainId;\n string tokenAddress;\n uint8 tokenDecimals;\n uint256 maxSwap;\n uint256 minSwap;\n uint256 swapFee;\n uint256 maxSwapFee;\n uint256 minSwapFee;\n bool hasUnderlying;\n bool isUnderlying;\n }\n\n struct Pool {\n address tokenAddress;\n uint256 chainId;\n address poolAddress;\n bool metaswap;\n }\n\n constructor() public {\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n }\n\n /**\n * @notice Returns a list of all existing token IDs converted to strings\n */\n function getAllTokenIDs() public view returns (string[] memory result) {\n uint256 length = _allTokenIDs.length;\n result = new string[](length);\n for (uint256 i = 0; i \u003c length; ++i) {\n result[i] = toString(_allTokenIDs[i]);\n }\n }\n\n function _getTokenID(string memory tokenAddress, uint256 chainID) internal view returns (string memory) {\n return toString(_tokenIDMap[chainID][tokenAddress]);\n }\n\n function getTokenID(string memory tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(tokenAddress), chainID);\n }\n\n /**\n * @notice Returns the token ID (string) of the cross-chain token inputted\n * @param tokenAddress address of token to get ID for\n * @param chainID chainID of which to get token ID for\n */\n function getTokenID(address tokenAddress, uint256 chainID) public view returns (string memory) {\n return _getTokenID(_toLower(toString(tokenAddress)), chainID);\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getToken(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns the full token config struct\n * @param tokenID String input of the token ID for the token\n * @param chainID Chain ID of which token address + config to get\n */\n function getTokenByID(string memory tokenID, uint256 chainID) public view returns (Token memory token) {\n return _tokens[toBytes32(tokenID)][chainID];\n }\n\n /**\n * @notice Returns token config struct, given an address and chainID\n * @param tokenAddress Matches the token ID by using a combo of address + chain ID\n * @param chainID Chain ID of which token to get config for\n */\n function getTokenByAddress(string memory tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(tokenAddress)]][chainID];\n }\n\n function getTokenByEVMAddress(address tokenAddress, uint256 chainID) public view returns (Token memory token) {\n return _tokens[_tokenIDMap[chainID][_toLower(toString(tokenAddress))]][chainID];\n }\n\n /**\n * @notice Returns true if the token has an underlying token -- meaning the token is deposited into the bridge\n * @param tokenID String to check if it is a withdraw/underlying token\n */\n function hasUnderlyingToken(string memory tokenID) public view returns (bool) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].hasUnderlying) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Returns which token is the underlying token to withdraw\n * @param tokenID string token ID\n */\n function getUnderlyingToken(string memory tokenID) public view returns (Token memory token) {\n bytes32 bytesTokenID = toBytes32(tokenID);\n Token[] memory _mcTokens = _allTokens[bytesTokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].isUnderlying) {\n return _mcTokens[i];\n }\n }\n }\n\n /**\n @notice Public function returning if token ID exists given a string\n */\n function isTokenIDExist(string memory tokenID) public view returns (bool) {\n return _isTokenIDExist(toBytes32(tokenID));\n }\n\n /**\n @notice Internal function returning if token ID exists given bytes32 version of the ID\n */\n function _isTokenIDExist(bytes32 tokenID) internal view returns (bool) {\n for (uint256 i = 0; i \u003c _allTokenIDs.length; ++i) {\n if (_allTokenIDs[i] == tokenID) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @notice Internal function which handles logic of setting token ID and dealing with mappings\n * @param tokenID bytes32 version of ID\n * @param chainID which chain to set the token config for\n * @param tokenToAdd Token object to set the mapping to\n */\n function _setTokenConfig(\n bytes32 tokenID,\n uint256 chainID,\n Token memory tokenToAdd\n ) internal returns (bool) {\n _tokens[tokenID][chainID] = tokenToAdd;\n if (!_isTokenIDExist(tokenID)) {\n _allTokenIDs.push(tokenID);\n }\n\n Token[] storage _mcTokens = _allTokens[tokenID];\n for (uint256 i = 0; i \u003c _mcTokens.length; ++i) {\n if (_mcTokens[i].chainId == chainID) {\n string memory oldToken = _mcTokens[i].tokenAddress;\n if (!compareStrings(tokenToAdd.tokenAddress, oldToken)) {\n _mcTokens[i].tokenAddress = tokenToAdd.tokenAddress;\n _tokenIDMap[chainID][oldToken] = keccak256(\"\");\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n }\n }\n }\n _mcTokens.push(tokenToAdd);\n _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;\n return true;\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n address tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n return\n setTokenConfig(\n tokenID,\n chainID,\n toString(tokenAddress),\n tokenDecimals,\n maxSwap,\n minSwap,\n swapFee,\n maxSwapFee,\n minSwapFee,\n hasUnderlying,\n isUnderlying\n );\n }\n\n /**\n * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function\n * @param tokenID string ID to set the token config object form\n * @param chainID chain ID to use for the token config object\n * @param tokenAddress token address of the token on the given chain\n * @param tokenDecimals decimals of token\n * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals\n * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals\n * @param swapFee percent based swap fee -- 10e6 == 10bps\n * @param maxSwapFee max swap fee to be charged - in native token decimals\n * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH\n * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()\n * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain\n */\n function setTokenConfig(\n string calldata tokenID,\n uint256 chainID,\n string memory tokenAddress,\n uint8 tokenDecimals,\n uint256 maxSwap,\n uint256 minSwap,\n uint256 swapFee,\n uint256 maxSwapFee,\n uint256 minSwapFee,\n bool hasUnderlying,\n bool isUnderlying\n ) public returns (bool) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n Token memory tokenToAdd;\n tokenToAdd.tokenAddress = _toLower(tokenAddress);\n tokenToAdd.tokenDecimals = tokenDecimals;\n tokenToAdd.maxSwap = maxSwap;\n tokenToAdd.minSwap = minSwap;\n tokenToAdd.swapFee = swapFee;\n tokenToAdd.maxSwapFee = maxSwapFee;\n tokenToAdd.minSwapFee = minSwapFee;\n tokenToAdd.hasUnderlying = hasUnderlying;\n tokenToAdd.isUnderlying = isUnderlying;\n tokenToAdd.chainId = chainID;\n\n return _setTokenConfig(toBytes32(tokenID), chainID, tokenToAdd);\n }\n\n function _calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) internal view returns (uint256) {\n Token memory token = _tokens[_tokenIDMap[chainID][tokenAddress]][chainID];\n uint256 calculatedSwapFee = amount.mul(token.swapFee).div(FEE_DENOMINATOR);\n if (calculatedSwapFee \u003e token.minSwapFee \u0026\u0026 calculatedSwapFee \u003c token.maxSwapFee) {\n return calculatedSwapFee;\n } else if (calculatedSwapFee \u003e token.maxSwapFee) {\n return token.maxSwapFee;\n } else {\n return token.minSwapFee;\n }\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n string memory tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(tokenAddress), chainID, amount);\n }\n\n /**\n * @notice Calculates bridge swap fee based on the destination chain's token transfer.\n * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on\n * @param tokenAddress address of the destination token to query token config for\n * @param chainID destination chain ID to query the token config for\n * @param amount in native token decimals\n * @return Fee calculated in token decimals\n */\n function calculateSwapFee(\n address tokenAddress,\n uint256 chainID,\n uint256 amount\n ) external view returns (uint256) {\n return _calculateSwapFee(_toLower(toString(tokenAddress)), chainID, amount);\n }\n\n // GAS PRICING\n\n /**\n * @notice sets the max gas price for a chain\n */\n function setMaxGasPrice(uint256 chainID, uint256 maxPrice) public {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));\n _maxGasPrice[chainID] = maxPrice;\n }\n\n /**\n * @notice gets the max gas price for a chain\n */\n function getMaxGasPrice(uint256 chainID) public view returns (uint256) {\n return _maxGasPrice[chainID];\n }\n\n // POOL CONFIG\n\n function getPoolConfig(address tokenAddress, uint256 chainID) external view returns (Pool memory) {\n return _pool[tokenAddress][chainID];\n }\n\n function setPoolConfig(\n address tokenAddress,\n uint256 chainID,\n address poolAddress,\n bool metaswap\n ) external returns (Pool memory) {\n require(hasRole(BRIDGEMANAGER_ROLE, msg.sender), \"Caller is not Bridge Manager\");\n Pool memory newPool = Pool(tokenAddress, chainID, poolAddress, metaswap);\n _pool[tokenAddress][chainID] = newPool;\n return newPool;\n }\n\n // UTILITY FUNCTIONS\n\n function toString(bytes32 data) internal pure returns (string memory) {\n uint8 i = 0;\n while (i \u003c 32 \u0026\u0026 data[i] != 0) {\n ++i;\n }\n bytes memory bs = new bytes(i);\n for (uint8 j = 0; j \u003c i; ++j) {\n bs[j] = data[j];\n }\n return string(bs);\n }\n\n // toBytes32 converts a string to a bytes 32\n function toBytes32(string memory str) internal pure returns (bytes32 result) {\n require(bytes(str).length \u003c= 32);\n assembly {\n result := mload(add(str, 32))\n }\n }\n\n function toString(address x) internal pure returns (string memory) {\n bytes memory s = new bytes(40);\n for (uint256 i = 0; i \u003c 20; i++) {\n bytes1 b = bytes1(uint8(uint256(uint160(x)) / (2**(8 * (19 - i)))));\n bytes1 hi = bytes1(uint8(b) / 16);\n bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));\n s[2 * i] = char(hi);\n s[2 * i + 1] = char(lo);\n }\n\n string memory addrPrefix = \"0x\";\n\n return concat(addrPrefix, string(s));\n }\n\n function concat(string memory _x, string memory _y) internal pure returns (string memory) {\n bytes memory _xBytes = bytes(_x);\n bytes memory _yBytes = bytes(_y);\n\n string memory _tmpValue = new string(_xBytes.length + _yBytes.length);\n bytes memory _newValue = bytes(_tmpValue);\n\n uint256 i;\n uint256 j;\n\n for (i = 0; i \u003c _xBytes.length; i++) {\n _newValue[j++] = _xBytes[i];\n }\n\n for (i = 0; i \u003c _yBytes.length; i++) {\n _newValue[j++] = _yBytes[i];\n }\n\n return string(_newValue);\n }\n\n function char(bytes1 b) internal pure returns (bytes1 c) {\n if (uint8(b) \u003c 10) {\n c = bytes1(uint8(b) + 0x30);\n } else {\n c = bytes1(uint8(b) + 0x57);\n }\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function _toLower(string memory str) internal pure returns (string memory) {\n bytes memory bStr = bytes(str);\n bytes memory bLower = new bytes(bStr.length);\n for (uint256 i = 0; i \u003c bStr.length; i++) {\n // Uppercase character...\n if ((uint8(bStr[i]) \u003e= 65) \u0026\u0026 (uint8(bStr[i]) \u003c= 90)) {\n // So we add 32 to make it lowercase\n bLower[i] = bytes1(uint8(bStr[i]) + 32);\n } else {\n bLower[i] = bStr[i];\n }\n }\n return string(bLower);\n }\n}\n\n\n\n","language":"Solidity","languageVersion":"0.6.12","compilerVersion":"0.6.12","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"25871:6594:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;","srcMapRuntime":"25871:6594:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Wrappers over Solidity's arithmetic operations with added overflow checks. Arithmetic operations in Solidity wrap on overflow. This can easily result in bugs, because programmers usually assume that an overflow raises an error, which is the standard behavior in high level programming languages. `SafeMath` restores this intuition by reverting the transaction when an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always.","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Wrappers over Solidity's arithmetic operations with added overflow checks. Arithmetic operations in Solidity wrap on overflow. This can easily result in bugs, because programmers usually assume that an overflow raises an error, which is the standard behavior in high level programming languages. `SafeMath` restores this intuition by reverting the transaction when an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always.\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/solidity/BridgeConfigV3_flat.sol\":\"SafeMath\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/solidity/BridgeConfigV3_flat.sol\":{\"keccak256\":\"0xed97c5e2e62a33d867264cf25c64f2215222ad36723fee31796bfd0930a0fffd\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ed38243be38158798b1de0aaa7ba9a22df5f9bca3a1ff9ba814719c9e0391e26\",\"dweb:/ipfs/Qmebz2oFzXzZdE27FNbhhYbvVsDXKPy9pYrBxEVXQDaC4X\"]}},\"version\":1}"},"hashes":{}}}