Overview
S Balance
0 S
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
GatewayUpgradeable
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 100000000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "./AssetVault.sol"; import "./SignatureUtils.sol"; import "./IDapp.sol"; import "./IAdditionalSecurityModule.sol"; import "./libraries/ValsetUpdate.sol"; import "./Utils.sol"; /** @title Facilitates request to Router, validator set update and request from router. @author Router Protocol */ contract GatewayUpgradeable is Initializable, PausableUpgradeable, AccessControlUpgradeable, UUPSUpgradeable, ReentrancyGuardUpgradeable { using ValsetUpdate for Utils.ValsetArgs; bytes constant INVALID_REQUEST_RESPONSE = abi.encode(false, abi.encode("")); // bytes32 encoding of the string "checkpoint" bytes32 constant CHECK_POINT_METHOD_NAME = 0x636865636b706f696e7400000000000000000000000000000000000000000000; // bytes32 encoding of "iReceive" bytes32 constant IRECEIVE_METHOD_NAME = 0x6952656365697665000000000000000000000000000000000000000000000000; // bytes32 encoding of "iAck" bytes32 constant IACK_METHOD_NAME = 0x6941636b00000000000000000000000000000000000000000000000000000000; bytes32 public constant RESOURCE_SETTER = keccak256("RESOURCE_SETTER"); bytes32 public constant PAUSER = keccak256("PAUSER"); // storage string public chainId; // address of the vault contract AssetVault public vault; // current version for encoding decoding of request packet uint256 public currentVersion; // nonce for requestToRouter Messages uint256 public eventNonce; uint256 public stateLastValsetNonce; // last validated ValSet Checkpoint bytes32 public stateLastValsetCheckpoint; // default fee for "iSend" uint256 public iSendDefaultFee; // cross-chain nonce validation mapping for incoming requests from different chains // (srcChainid{string} => nonce{uint256} => handled{bool})) mapping(string => mapping(uint256 => bool)) public nonceExecuted; // cross-chain nonce validation mapping for acknowledgements // nonce{uint256} => handled{bool})) mapping(uint256 => bool) public ackNonceExecuted; // requestMetadata: // abi.encodePacked ( // uint64 destGasLimit; // uint64 destGasPrice; // uint64 ackGasLimit; // uint64 ackGasPrice; // uint128 relayerFees; // uint8 ackType; // bool isReadCall; // string asmAddress; // ) // } // requestPacket: // abi.encode ( // string destContractAddress, // bytes payload // ) event ISendEvent( uint256 version, uint256 routeAmount, uint256 indexed eventNonce, address requestSender, string srcChainId, string destChainId, string routeRecipient, bytes requestMetadata, bytes requestPacket ); event IReceiveEvent( uint256 indexed requestIdentifier, uint256 indexed eventNonce, string srcChainId, string destChainId, string relayerRouterAddress, string requestSender, bytes execData, bool execStatus ); // This is CrossTalk Acknowledgement Request Submit Event event IAckEvent( uint256 indexed eventNonce, uint256 indexed requestIdentifier, string relayerRouterAddress, string chainId, bytes data, bool success ); event ValsetUpdatedEvent( uint256 indexed _newValsetNonce, uint256 indexed _eventNonce, string srcChainId, address[] _validators, uint64[] _powers ); event SetVaultEvent(address vaultAddress); event BridgeFeeUpdatedEvent(uint256 oldFeeValue, uint256 newFeeValue); event SetDappMetadataEvent(uint256 indexed eventNonce, address dappAddress, string chainId, string feePayerAddress); function pause() external onlyRole(PAUSER) { _pause(); } function unpause() external onlyRole(PAUSER) { _unpause(); } // Make a new checkpoint from the supplied validator set // A checkpoint is a hash of all relevant information about the valset. This is stored by the contract, // instead of storing the information directly. This saves on storage and gas. // The format of the checkpoint is: // h(_chainId, "checkpoint", valsetNonce, validators[], powers[]) // Where h is the keccak256 hash function. // The validator powers must be decreasing or equal. This is important for checking the signatures on the // next valset, since it allows the caller to stop verifying signatures once a quorum of signatures have been verified. function makeCheckpoint(Utils.ValsetArgs memory _valsetArgs) internal pure returns (bytes32) { bytes32 checkpoint = keccak256( abi.encode(CHECK_POINT_METHOD_NAME, _valsetArgs.valsetNonce, _valsetArgs.validators, _valsetArgs.powers) ); return checkpoint; } // This updates the valset by checking that the validators in the current valset have signed off on the // new valset. The signatures supplied are the signatures of the current valset over the checkpoint hash // generated from the new valset. // Anyone can call this function, but they must supply valid signatures of CONSTANT_POWER_THRESHOLD of the current valset over // the new valset. function updateValset( // The new version of the validator set Utils.ValsetArgs calldata _newValset, // The current validators that approve the change Utils.ValsetArgs calldata _currentValset, // These are arrays of the parts of the current validator's signatures bytes[] calldata _sigs ) external whenNotPaused nonReentrant { // CHECKS ValsetUpdate.updateValsetChecks(_newValset, _currentValset); // Check that the supplied current validator set matches the saved checkpoint if (makeCheckpoint(_currentValset) != stateLastValsetCheckpoint) { revert Utils.IncorrectCheckpoint(); } // Check that enough current validators have signed off on the new validator set bytes32 newCheckpoint = makeCheckpoint(_newValset); bytes32 digest = _make_digest(newCheckpoint); SignatureUtils.checkValidatorSignatures(_currentValset, _sigs, digest, Utils.CONSTANT_POWER_THRESHOLD); // ACTIONS // Stored to be used next time to validate that the valset // supplied by the caller is correct. stateLastValsetCheckpoint = newCheckpoint; // Store new nonce stateLastValsetNonce = _newValset.valsetNonce; eventNonce++; emit ValsetUpdatedEvent(_newValset.valsetNonce, eventNonce, chainId, _newValset.validators, _newValset.powers); } /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } /** @notice Initializes Bridge, creates and grants {msg.sender} the admin role, creates and grants {initialRelayers} the relayer role. @param _chainId ID of chain the Bridge contract exists on. */ function initialize( string memory _chainId, address[] memory _validators, uint64[] memory _powers, uint64 valsetNonce ) external initializer { // CHECKS // Check that validators, powers, and signatures (v,r,s) set is well-formed if (_validators.length != _powers.length || _validators.length == 0) { revert Utils.MalformedCurrentValidatorSet(); } // Check cumulative power to ensure the contract has sufficient power to actually // pass a vote // point -> if due to special order our set to Utils.ValsetArgs memory _valset; _valset = Utils.ValsetArgs(_validators, _powers, valsetNonce); ValsetUpdate.validateValsetPower(_valset); bytes32 newCheckpoint = makeCheckpoint(_valset); // ACTIONS __ReentrancyGuard_init(); __AccessControl_init(); __Pausable_init(); // Constructor Fx _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(RESOURCE_SETTER, msg.sender); _grantRole(PAUSER, msg.sender); chainId = _chainId; eventNonce = 1; stateLastValsetNonce = valsetNonce; stateLastValsetCheckpoint = newCheckpoint; currentVersion = 1; emit ValsetUpdatedEvent(valsetNonce, eventNonce, chainId, _validators, _powers); // Constructor Fx } function _authorizeUpgrade(address newImplementation) internal virtual override onlyRole(DEFAULT_ADMIN_ROLE) {} function setCurrentVersion(uint256 newVersion) external onlyRole(RESOURCE_SETTER) { currentVersion = newVersion; } function setBridgeFees(uint256 _iSendDefaultFee) external onlyRole(RESOURCE_SETTER) { // default fee for "sendCrossChainRequest" assert(_iSendDefaultFee < Utils.I_DEFAULT_FEE_UPPER_LIMIT); emit BridgeFeeUpdatedEvent(iSendDefaultFee, _iSendDefaultFee); iSendDefaultFee = _iSendDefaultFee; } /// @notice Used to withdraw fee /// @param recipient Address to withdraw tokens to. function withdrawFee( address tokenAddress, address payable recipient, uint256 gasLimit, uint256 amount ) external onlyRole(DEFAULT_ADMIN_ROLE) { // default fee for "sendCrossChainRequest" if (tokenAddress != address(0)) { (bool success, ) = tokenAddress.call{ gas: gasLimit }( abi.encodeWithSignature("transfer(address,uint256)", recipient, amount) ); require(success, "Failed to send Tokens!"); } else { (bool success, ) = recipient.call{ gas: gasLimit, value: amount }(""); require(success, "Failed to send Eth!"); } } function setVault(address _vaultAddress) external onlyRole(DEFAULT_ADMIN_ROLE) { // "empty address" => "C02" if (_vaultAddress == address(0)) { revert Utils.C02(); } vault = AssetVault(_vaultAddress); emit SetVaultEvent(_vaultAddress); } function setDappMetadata(string memory feePayerAddress) external payable whenNotPaused returns (uint256) { // "fees too low" => "C03" if (msg.value < iSendDefaultFee) { revert Utils.C03(); } eventNonce++; emit SetDappMetadataEvent(eventNonce, msg.sender, chainId, feePayerAddress); return eventNonce; } function iSend( uint256 version, uint256 routeAmount, string calldata routeRecipient, string calldata destChainId, bytes calldata requestMetadata, bytes calldata requestPacket ) external payable whenNotPaused returns (uint256) { // "fees too low" => "C03" if (msg.value < iSendDefaultFee) { revert Utils.C03(); } if (routeAmount > 0) { // "empty recipient" => "C04" // keccak256(bytes("")) = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 // TODO: Can we remove if ( keccak256(bytes(routeRecipient)) == 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 ) { revert Utils.C04(); } vault.deposit(routeAmount, msg.sender); } ++eventNonce; emitISendEvent(version, routeAmount, destChainId, routeRecipient, requestMetadata, requestPacket); return eventNonce; } function emitISendEvent( uint256 version, uint256 routeAmount, string calldata destChainId, string calldata routeRecipient, bytes calldata requestMetadata, bytes calldata requestPacket ) internal { emit ISendEvent( version, routeAmount, eventNonce, msg.sender, chainId, destChainId, routeRecipient, requestMetadata, requestPacket ); } function checkCheckpointAndVerifySigs( Utils.ValsetArgs calldata _valsetArgs, bytes[] calldata _sigs, bytes memory encodedABI ) internal view { if (makeCheckpoint(_valsetArgs) != stateLastValsetCheckpoint) { revert Utils.IncorrectCheckpoint(); } bytes32 messagehash = keccak256(encodedABI); bytes32 digest = _make_digest(messagehash); SignatureUtils.checkValidatorSignatures(_valsetArgs, _sigs, digest, Utils.CONSTANT_POWER_THRESHOLD); } function _make_digest(bytes32 data) private pure returns (bytes32 _digest) { _digest = keccak256(abi.encodePacked(Utils.MSG_PREFIX, data)); } function iReceive( Utils.ValsetArgs calldata _currentValset, bytes[] calldata _sigs, Utils.RequestPayload memory requestPayload, string memory relayerRouterAddress ) external whenNotPaused nonReentrant { bytes memory encodedABI = abi.encode( IRECEIVE_METHOD_NAME, requestPayload.routeAmount, requestPayload.requestIdentifier, requestPayload.requestTimestamp, requestPayload.srcChainId, requestPayload.routeRecipient, chainId, requestPayload.asmAddress, requestPayload.requestSender, requestPayload.handlerAddress, requestPayload.packet, requestPayload.isReadCall ); checkCheckpointAndVerifySigs(_currentValset, _sigs, encodedABI); // "cross-chain request message already handled" => "C06" if (nonceExecuted[requestPayload.srcChainId][requestPayload.requestIdentifier] == true) { revert Utils.C06(); } if (requestPayload.routeAmount > 0) { //caution: make sure recipient should be correct if (requestPayload.routeRecipient == address(0)) { revert Utils.InvalidRecipient(); } vault.handleWithdraw(requestPayload.routeAmount, requestPayload.routeRecipient); } // (bytes memory handler, bytes memory packet) = abi.decode(requestPayload.requestPacket, (bytes, bytes)); bool isValidRequest = true; if (requestPayload.asmAddress != address(0) && isContract(requestPayload.asmAddress)) { IAdditionalSecurityModule asm = IAdditionalSecurityModule(requestPayload.asmAddress); isValidRequest = asm.verifyCrossChainRequest( requestPayload.requestIdentifier, requestPayload.requestTimestamp, requestPayload.requestSender, requestPayload.srcChainId, requestPayload.packet, requestPayload.handlerAddress ); } nonceExecuted[requestPayload.srcChainId][requestPayload.requestIdentifier] = true; ++eventNonce; if (!isValidRequest) { // Since we are sending a specific set of bytes (invalid request response), we can remove exeCode emit IReceiveEvent( requestPayload.requestIdentifier, eventNonce, requestPayload.srcChainId, chainId, relayerRouterAddress, requestPayload.requestSender, INVALID_REQUEST_RESPONSE, false ); return; } bytes memory execData; bool execFlag; if (!requestPayload.isReadCall) { (execFlag, execData) = requestPayload.handlerAddress.call( abi.encodeWithSelector( IDapp.iReceive.selector, requestPayload.requestSender, requestPayload.packet, requestPayload.srcChainId ) ); } else { (execFlag, execData) = requestPayload.handlerAddress.staticcall(requestPayload.packet); } if (!execFlag && gasleft() < Utils.MIN_GAS_THRESHHOLD) revert Utils.MessageExcecutionFailedWithLowGas(); emit IReceiveEvent( requestPayload.requestIdentifier, eventNonce, requestPayload.srcChainId, chainId, relayerRouterAddress, requestPayload.requestSender, execData, execFlag ); } function iAck( // The validators that approve the call Utils.ValsetArgs calldata _currentValset, // These are arrays of the parts of the validators signatures bytes[] calldata _sigs, Utils.CrossChainAckPayload memory crossChainAckPayload, string memory relayerRouterAddress ) external whenNotPaused nonReentrant { // chainId data is present inside the signature validation // valsetArgs validation will be handled by the makeCheckPoint function if (ackNonceExecuted[crossChainAckPayload.requestIdentifier] == true) { revert Utils.C06(); } if (nonceExecuted[crossChainAckPayload.destChainId][crossChainAckPayload.ackRequestIdentifier] == true) { revert Utils.C07(); } bytes memory encodedABI = abi.encode( // bytes32 encoding of "iAck" IACK_METHOD_NAME, chainId, crossChainAckPayload.requestIdentifier, crossChainAckPayload.ackRequestIdentifier, crossChainAckPayload.destChainId, crossChainAckPayload.requestSender, crossChainAckPayload.execData, crossChainAckPayload.execFlag ); checkCheckpointAndVerifySigs(_currentValset, _sigs, encodedABI); ackNonceExecuted[crossChainAckPayload.requestIdentifier] = true; nonceExecuted[crossChainAckPayload.destChainId][crossChainAckPayload.ackRequestIdentifier] = true; uint256 nonce; unchecked { nonce = ++eventNonce; } // address handler = toAddress(crossChainAckPayload.requestSender); (bool success, bytes memory data) = crossChainAckPayload.requestSender.call{ gas: gasleft() }( abi.encodeWithSelector( IDapp.iAck.selector, crossChainAckPayload.requestIdentifier, crossChainAckPayload.execFlag, crossChainAckPayload.execData ) ); if (!success && gasleft() < Utils.MIN_GAS_THRESHHOLD) revert Utils.MessageExcecutionFailedWithLowGas(); emit IAckEvent(nonce, crossChainAckPayload.requestIdentifier, relayerRouterAddress, chainId, data, success); } function isContract(address addr) internal view returns (bool) { uint256 size; assembly { size := extcodesize(addr) } return size > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * 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: * * ```solidity * 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}: * * ```solidity * 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. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(account), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev 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. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev 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 revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev 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._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev 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`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev 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. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev 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`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.0; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. * * _Available since v4.8.3._ */ interface IERC1967Upgradeable { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/IERC1967Upgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ */ abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { AddressUpgradeable.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeTo(address newImplementation) public virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMathUpgradeable { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._ * _Available since v4.9 for `string`, `bytes`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; import "./math/SignedMathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * 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: * * ```solidity * 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}: * * ```solidity * 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. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev 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. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev 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 revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev 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._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev 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`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev 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. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev 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`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../utils/Context.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { _spendAllowance(account, _msgSender(), amount); _burn(account, amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.21; import "./ERC20Token.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract AssetVault is ReentrancyGuard { address public immutable gateway; ERC20Token public immutable routeToken; constructor(address gatewayAddress, address routeTokenAddress) { gateway = gatewayAddress; routeToken = ERC20Token(routeTokenAddress); } event AssetBurned(uint256 amount, address indexed sender); event AssetMinted(uint256 amount, address indexed recipient); /// @notice function to deposit route token /// @param amount is the qty of Route token to burn /// @param caller is invoker of gateway contract function deposit(uint256 amount, address caller) external { require(msg.sender == gateway, "!Gateway"); routeToken.burnFrom(caller, amount); // it any failure it will revert emit AssetBurned(amount, caller); } /// @notice function to withdraw route token /// @param amount is the qty of Route token to mint /// @param recipient is the address where router token will be transfered function handleWithdraw(uint256 amount, address recipient) external { require(msg.sender == gateway, "!Gateway"); routeToken.mint(recipient, amount); emit AssetMinted(amount, recipient); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; contract ERC20Token is ERC20, ERC20Burnable, Pausable, AccessControl { bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); uint8 decimal; constructor(string memory _name, string memory _symbol, uint8 _decimal) ERC20(_name, _symbol) { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(PAUSER_ROLE, msg.sender); _grantRole(MINTER_ROLE, msg.sender); decimal = _decimal; } function decimals() public view virtual override returns (uint8) { return decimal; } function pause() public onlyRole(PAUSER_ROLE) { _pause(); } function unpause() public onlyRole(PAUSER_ROLE) { _unpause(); } function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) { _mint(to, amount); } function _burn(address account, uint256 amount) internal override onlyRole(MINTER_ROLE) { super._burn(account, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal whenNotPaused override { super._beforeTokenTransfer(from, to, amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; /** * @dev IAdditionalSecurityModule flow Interface. */ interface IAdditionalSecurityModule { function verifyCrossChainRequest( uint256 requestIdentifier, uint256 requestTimestamp, string calldata requestSender, string calldata srcChainId, bytes calldata packet, address handler ) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; /** * @dev Interface of the Gateway Self External Calls. */ interface IDapp { function iReceive( string memory requestSender, bytes memory packet, string memory srcChainId ) external returns (bytes memory); function iAck(uint256 requestIdentifier, bool execFlags, bytes memory execData) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; library ECDSA { error InvalidS(); error InvalidV(); error InvalidEcdsaSignature(); /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes32 r, bytes32 s, uint8 v) internal pure returns (address signer) { // Check the signature length // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) revert InvalidS(); // If the signature is valid (and not malleable), return the signer address if ((signer = ecrecover(hash, v, r, s)) == address(0)) revert InvalidEcdsaSignature(); } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; import "../Utils.sol"; import "../SignatureUtils.sol"; library ValsetUpdate { function validateValsetPower(Utils.ValsetArgs calldata _newValset) public pure { uint64 cumulativePower = 0; for (uint64 i = 0; i < _newValset.powers.length; i++) { cumulativePower = cumulativePower + _newValset.powers[i]; if (cumulativePower > Utils.CONSTANT_POWER_THRESHOLD) { break; } } if (cumulativePower <= Utils.CONSTANT_POWER_THRESHOLD) { revert Utils.InsufficientPower({ cumulativePower: cumulativePower, powerThreshold: Utils.CONSTANT_POWER_THRESHOLD }); } } function updateValsetChecks( // The new version of the validator set Utils.ValsetArgs calldata _newValset, // The current validators that approve the change Utils.ValsetArgs calldata _currentValset ) public pure { // Check that the valset nonce is greater than the old one if (_newValset.valsetNonce <= _currentValset.valsetNonce) { revert Utils.InvalidValsetNonce({ newNonce: _newValset.valsetNonce, currentNonce: _currentValset.valsetNonce }); } // Check that the valset nonce is less than a million nonces forward from the old one // this makes it difficult for an attacker to lock out the contract by getting a single // bad validator set through with uint256 max nonce if (_newValset.valsetNonce > _currentValset.valsetNonce + 1000000) { revert Utils.InvalidValsetNonce({ newNonce: _newValset.valsetNonce, currentNonce: _currentValset.valsetNonce }); } // Check that new validators and powers set is well-formed if (_newValset.validators.length != _newValset.powers.length || _newValset.validators.length == 0) { revert Utils.MalformedNewValidatorSet(); } // Check cumulative power to ensure the contract has sufficient power to actually // pass a vote validateValsetPower(_newValset); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; // import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "./libraries/ECDSA.sol"; import "./Utils.sol"; library SignatureUtils { error InvalidSignatureLength(); function verifySig( address _signer, bytes32 _messageDigest, bytes32 r, bytes32 s, uint8 v ) private pure returns (bool) { return _signer == ECDSA.recover(_messageDigest, r, s, v); } function checkValidatorSignatures( // The current validator set and their powers Utils.ValsetArgs calldata _currentValset, // The current validator's signatures bytes[] calldata _sigs, // This is what we are checking they have signed bytes32 _theHash, uint64 _powerThreshold ) internal pure { uint64 cumulativePower = 0; for (uint64 i = 0; i < _currentValset.validators.length; i++) { if (_sigs[i].length != 65) revert InvalidSignatureLength(); bytes memory sig = _sigs[i]; // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(sig, 0x20)) s := mload(add(sig, 0x40)) v := byte(0, mload(add(sig, 0x60))) } // If v is set to 0, this signifies that it was not possible to get a signature // from this validator and we skip evaluation // (In a valid signature, it is either 27 or 28) if (v != 0) { // Check that the current validator has signed off on the hash if (!verifySig(_currentValset.validators[i], _theHash, r, s, v)) { revert Utils.InvalidSignature(); } // Sum up cumulative power cumulativePower = cumulativePower + _currentValset.powers[i]; // Break early to avoid wasting gas if (cumulativePower > _powerThreshold) { break; } } } // Check that there was enough power if (cumulativePower <= _powerThreshold) { revert Utils.InsufficientPower(cumulativePower, _powerThreshold); } // Success } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; library Utils { // This is used purely to avoid stack too deep errors // represents everything about a given validator set struct ValsetArgs { // the validators in this set, represented by an Ethereum address address[] validators; // the powers of the given validators in the same order as above uint64[] powers; // the nonce of this validator set uint256 valsetNonce; } struct RequestPayload { uint256 routeAmount; uint256 requestIdentifier; uint256 requestTimestamp; string srcChainId; address routeRecipient; string destChainId; address asmAddress; string requestSender; address handlerAddress; bytes packet; bool isReadCall; } struct CrossChainAckPayload { uint256 requestIdentifier; uint256 ackRequestIdentifier; string destChainId; address requestSender; bytes execData; bool execFlag; } enum AckType { NO_ACK, ACK_ON_SUCCESS, ACK_ON_ERROR, ACK_ON_BOTH } error IncorrectCheckpoint(); error C01(); error C02(); error C03(); error C04(); error C05(); error C06(); error C07(); error WrongDestId(); error InvalidRecipient(); error InvalidValsetNonce(uint256 newNonce, uint256 currentNonce); error MalformedNewValidatorSet(); error MalformedCurrentValidatorSet(); error InsufficientPower(uint64 cumulativePower, uint64 powerThreshold); error InvalidSignature(); error MessageExcecutionFailedWithLowGas(); // constants string constant MSG_PREFIX = "\x19Ethereum Signed Message:\n32"; // The number of 'votes' required to execute a valset // update or batch execution, set to 2/3 of 2^32 uint64 constant CONSTANT_POWER_THRESHOLD = 2863311531; // Upper Cap for I_DEFAULT_FEE 10 * 10^18 uint256 constant I_DEFAULT_FEE_UPPER_LIMIT = 10000000000000000000; uint256 constant MIN_GAS_THRESHHOLD = 75000; }
{ "evmVersion": "paris", "metadata": { "bytecodeHash": "none" }, "optimizer": { "enabled": true, "runs": 100000000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": { "contracts/libraries/ValsetUpdate.sol": { "ValsetUpdate": "0xac589f48f94134db8671acd31f4da55ce43e318c" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"C02","type":"error"},{"inputs":[],"name":"C03","type":"error"},{"inputs":[],"name":"C04","type":"error"},{"inputs":[],"name":"C06","type":"error"},{"inputs":[],"name":"C07","type":"error"},{"inputs":[],"name":"IncorrectCheckpoint","type":"error"},{"inputs":[{"internalType":"uint64","name":"cumulativePower","type":"uint64"},{"internalType":"uint64","name":"powerThreshold","type":"uint64"}],"name":"InsufficientPower","type":"error"},{"inputs":[],"name":"InvalidEcdsaSignature","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidS","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidSignatureLength","type":"error"},{"inputs":[],"name":"MalformedCurrentValidatorSet","type":"error"},{"inputs":[],"name":"MessageExcecutionFailedWithLowGas","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldFeeValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newFeeValue","type":"uint256"}],"name":"BridgeFeeUpdatedEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"eventNonce","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"requestIdentifier","type":"uint256"},{"indexed":false,"internalType":"string","name":"relayerRouterAddress","type":"string"},{"indexed":false,"internalType":"string","name":"chainId","type":"string"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"}],"name":"IAckEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestIdentifier","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"eventNonce","type":"uint256"},{"indexed":false,"internalType":"string","name":"srcChainId","type":"string"},{"indexed":false,"internalType":"string","name":"destChainId","type":"string"},{"indexed":false,"internalType":"string","name":"relayerRouterAddress","type":"string"},{"indexed":false,"internalType":"string","name":"requestSender","type":"string"},{"indexed":false,"internalType":"bytes","name":"execData","type":"bytes"},{"indexed":false,"internalType":"bool","name":"execStatus","type":"bool"}],"name":"IReceiveEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"version","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"routeAmount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"eventNonce","type":"uint256"},{"indexed":false,"internalType":"address","name":"requestSender","type":"address"},{"indexed":false,"internalType":"string","name":"srcChainId","type":"string"},{"indexed":false,"internalType":"string","name":"destChainId","type":"string"},{"indexed":false,"internalType":"string","name":"routeRecipient","type":"string"},{"indexed":false,"internalType":"bytes","name":"requestMetadata","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"requestPacket","type":"bytes"}],"name":"ISendEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"eventNonce","type":"uint256"},{"indexed":false,"internalType":"address","name":"dappAddress","type":"address"},{"indexed":false,"internalType":"string","name":"chainId","type":"string"},{"indexed":false,"internalType":"string","name":"feePayerAddress","type":"string"}],"name":"SetDappMetadataEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vaultAddress","type":"address"}],"name":"SetVaultEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_newValsetNonce","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_eventNonce","type":"uint256"},{"indexed":false,"internalType":"string","name":"srcChainId","type":"string"},{"indexed":false,"internalType":"address[]","name":"_validators","type":"address[]"},{"indexed":false,"internalType":"uint64[]","name":"_powers","type":"uint64[]"}],"name":"ValsetUpdatedEvent","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESOURCE_SETTER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"ackNonceExecuted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chainId","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eventNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address[]","name":"validators","type":"address[]"},{"internalType":"uint64[]","name":"powers","type":"uint64[]"},{"internalType":"uint256","name":"valsetNonce","type":"uint256"}],"internalType":"struct Utils.ValsetArgs","name":"_currentValset","type":"tuple"},{"internalType":"bytes[]","name":"_sigs","type":"bytes[]"},{"components":[{"internalType":"uint256","name":"requestIdentifier","type":"uint256"},{"internalType":"uint256","name":"ackRequestIdentifier","type":"uint256"},{"internalType":"string","name":"destChainId","type":"string"},{"internalType":"address","name":"requestSender","type":"address"},{"internalType":"bytes","name":"execData","type":"bytes"},{"internalType":"bool","name":"execFlag","type":"bool"}],"internalType":"struct Utils.CrossChainAckPayload","name":"crossChainAckPayload","type":"tuple"},{"internalType":"string","name":"relayerRouterAddress","type":"string"}],"name":"iAck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address[]","name":"validators","type":"address[]"},{"internalType":"uint64[]","name":"powers","type":"uint64[]"},{"internalType":"uint256","name":"valsetNonce","type":"uint256"}],"internalType":"struct Utils.ValsetArgs","name":"_currentValset","type":"tuple"},{"internalType":"bytes[]","name":"_sigs","type":"bytes[]"},{"components":[{"internalType":"uint256","name":"routeAmount","type":"uint256"},{"internalType":"uint256","name":"requestIdentifier","type":"uint256"},{"internalType":"uint256","name":"requestTimestamp","type":"uint256"},{"internalType":"string","name":"srcChainId","type":"string"},{"internalType":"address","name":"routeRecipient","type":"address"},{"internalType":"string","name":"destChainId","type":"string"},{"internalType":"address","name":"asmAddress","type":"address"},{"internalType":"string","name":"requestSender","type":"string"},{"internalType":"address","name":"handlerAddress","type":"address"},{"internalType":"bytes","name":"packet","type":"bytes"},{"internalType":"bool","name":"isReadCall","type":"bool"}],"internalType":"struct Utils.RequestPayload","name":"requestPayload","type":"tuple"},{"internalType":"string","name":"relayerRouterAddress","type":"string"}],"name":"iReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"version","type":"uint256"},{"internalType":"uint256","name":"routeAmount","type":"uint256"},{"internalType":"string","name":"routeRecipient","type":"string"},{"internalType":"string","name":"destChainId","type":"string"},{"internalType":"bytes","name":"requestMetadata","type":"bytes"},{"internalType":"bytes","name":"requestPacket","type":"bytes"}],"name":"iSend","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"iSendDefaultFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_chainId","type":"string"},{"internalType":"address[]","name":"_validators","type":"address[]"},{"internalType":"uint64[]","name":"_powers","type":"uint64[]"},{"internalType":"uint64","name":"valsetNonce","type":"uint64"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"nonceExecuted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"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":"_iSendDefaultFee","type":"uint256"}],"name":"setBridgeFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newVersion","type":"uint256"}],"name":"setCurrentVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"feePayerAddress","type":"string"}],"name":"setDappMetadata","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_vaultAddress","type":"address"}],"name":"setVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stateLastValsetCheckpoint","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stateLastValsetNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address[]","name":"validators","type":"address[]"},{"internalType":"uint64[]","name":"powers","type":"uint64[]"},{"internalType":"uint256","name":"valsetNonce","type":"uint256"}],"internalType":"struct Utils.ValsetArgs","name":"_newValset","type":"tuple"},{"components":[{"internalType":"address[]","name":"validators","type":"address[]"},{"internalType":"uint64[]","name":"powers","type":"uint64[]"},{"internalType":"uint256","name":"valsetNonce","type":"uint256"}],"internalType":"struct Utils.ValsetArgs","name":"_currentValset","type":"tuple"},{"internalType":"bytes[]","name":"_sigs","type":"bytes[]"}],"name":"updateValset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract AssetVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a0604052306080523480156200001557600080fd5b506200002062000026565b620000e7565b600054610100900460ff1615620000935760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e5576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b60805161519b6200011f60003960008181610c3901528181610ce901528181611696015281816117460152611c1d015261519b6000f3fe6080604052600436106102195760003560e01c80637a40d0f71161011d578063a707d6b8116100b0578063e88fc81d1161007f578063ef15cbda11610064578063ef15cbda14610652578063f3a0ce4114610665578063fbfa77cf1461068557600080fd5b8063e88fc81d14610612578063ea76f6d71461063257600080fd5b8063a707d6b814610573578063d547741f1461058a578063d9dc8694146105aa578063db618e2a146105de57600080fd5b80639a8a0592116100ec5780639a8a0592146104f45780639d888e8614610516578063a0436a411461052d578063a217fddf1461055e57600080fd5b80637a40d0f71461042d5780637bed470a146104795780638456cb591461048c57806391d14854146104a157600080fd5b80633bcced29116101b05780634f1ef2861161017f57806352d1902d1161016457806352d1902d146103e05780635c975abb146103f55780636817031b1461040d57600080fd5b80634f1ef286146103ad57806351b6ac3f146103c057600080fd5b80633bcced29146103415780633f4ba83a1461036157806342fb207c1461037657806344bdf5a71461038d57600080fd5b8063248a9ca3116101ec578063248a9ca3146102b15780632f2ff15d146102e157806336568abe146103015780633659cfe61461032157600080fd5b806301ffc9a71461021e57806305cf22fc146102535780631c3e6ee6146102785780632205643a1461028f575b600080fd5b34801561022a57600080fd5b5061023e6102393660046138b3565b6106d8565b60405190151581526020015b60405180910390f35b34801561025f57600080fd5b5061026a6101645481565b60405190815260200161024a565b34801561028457600080fd5b5061026a6101625481565b34801561029b57600080fd5b506102af6102aa366004613af8565b610771565b005b3480156102bd57600080fd5b5061026a6102cc366004613c33565b60009081526097602052604090206001015490565b3480156102ed57600080fd5b506102af6102fc366004613c4c565b610b40565b34801561030d57600080fd5b506102af61031c366004613c4c565b610b6a565b34801561032d57600080fd5b506102af61033c366004613c7c565b610c22565b34801561034d57600080fd5b506102af61035c366004613c99565b610e27565b34801561036d57600080fd5b506102af610fc9565b34801561038257600080fd5b5061026a6101635481565b34801561039957600080fd5b506102af6103a8366004613d24565b610ffb565b6102af6103bb366004613ebe565b61167f565b3480156103cc57600080fd5b506102af6103db366004614020565b611871565b3480156103ec57600080fd5b5061026a611c03565b34801561040157600080fd5b5060335460ff1661023e565b34801561041957600080fd5b506102af610428366004613c7c565b611cef565b34801561043957600080fd5b5061023e6104483660046140b9565b8151602081840181018051610166825292820194820194909420919093529091526000908152604090205460ff1681565b61026a610487366004614140565b611dc2565b34801561049857600080fd5b506102af611f45565b3480156104ad57600080fd5b5061023e6104bc366004613c4c565b600091825260976020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561050057600080fd5b50610509611f77565b60405161024a9190614288565b34801561052257600080fd5b5061026a6101615481565b34801561053957600080fd5b5061023e610548366004613c33565b6101676020526000908152604090205460ff1681565b34801561056a57600080fd5b5061026a600081565b34801561057f57600080fd5b5061026a6101655481565b34801561059657600080fd5b506102af6105a5366004613c4c565b612006565b3480156105b657600080fd5b5061026a7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c81565b3480156105ea57600080fd5b5061026a7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb07881565b34801561061e57600080fd5b506102af61062d36600461429b565b61202b565b34801561063e57600080fd5b506102af61064d366004613c33565b61228e565b61026a6106603660046142e1565b612313565b34801561067157600080fd5b506102af610680366004613c33565b6123bc565b34801561069157600080fd5b50610160546106b39073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161024a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061076b57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b6107796123ed565b61078161245c565b81516000908152610167602052604090205460ff1615156001036107d1576040517fe4bb7a0400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61016682604001516040516107e69190614316565b9081526040805160209281900383019020848301516000908152925290205460ff161515600103610843576040517f92539f4600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60007f6941636b0000000000000000000000000000000000000000000000000000000060001b61015f846000015185602001518660400151876060015188608001518960a001516040516020016108a198979695949392919061441a565b60405160208183030381529060405290506108be868686846124d1565b8251600090815261016760205260409081902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660019081179091558185015191519091610166916109139190614316565b90815260408051602092819003830190208683015160009081529252812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016921515929092179091556101628054600101908190556060850151909190819073ffffffffffffffffffffffffffffffffffffffff165a875160a089015160808a01516040517fa4e2128800000000000000000000000000000000000000000000000000000000936109cd939092909160240161449c565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051610a569190614316565b60006040518083038160008787f1925050503d8060008114610a94576040519150601f19603f3d011682016040523d82523d6000602084013e610a99565b606091505b509150915081158015610aae5750620124f85a105b15610ae5576040517f9e82ca7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8560000151837f21a2de7d1ff2cd4fe0ffece047122598d9d5ef15a7aecff28f73c7deae9d64db8761015f8587604051610b2294939291906144c6565b60405180910390a350505050610b39600161012d55565b5050505050565b600082815260976020526040902060010154610b5b81612545565b610b65838361254f565b505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610c14576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b610c1e8282612643565b5050565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163003610ce7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610c0b565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610d5c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610dff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610c0b565b610e08816126fe565b60408051600080825260208201909252610e2491839190612709565b50565b610e2f6123ed565b610e3761245c565b6040517fa0c8e6a900000000000000000000000000000000000000000000000000000000815273ac589f48f94134db8671acd31f4da55ce43e318c9063a0c8e6a990610e899087908790600401614644565b60006040518083038186803b158015610ea157600080fd5b505af4158015610eb5573d6000803e3d6000fd5b5050505061016454610ecf84610eca90614669565b612908565b14610f06576040517f723a340300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610f14610eca86614669565b90506000610f218261298e565b9050610f348585858463aaaaaaab6129f5565b6101648290556040860135610163556101628054906000610f5483614729565b90915550506101625460408701357f20d5dcc846f7451afb9c8dc6dbf5f2242d04549ae17eb976f19b36cb4d7e165661015f610f908a80614761565b610f9d60208d018d614761565b604051610fae9594939291906147c9565b60405180910390a35050610fc3600161012d55565b50505050565b7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c610ff381612545565b610e24612c62565b6110036123ed565b61100b61245c565b60007f695265636569766500000000000000000000000000000000000000000000000060001b8360000151846020015185604001518660600151876080015161015f8960c001518a60e001518b61010001518c61012001518d61014001516040516020016110849c9b9a9998979695949392919061487d565b60405160208183030381529060405290506110a1868686846124d1565b61016683606001516040516110b69190614316565b9081526040805160209281900383019020858301516000908152925290205460ff161515600103611113576040517fe4bb7a0400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82511561120157608083015173ffffffffffffffffffffffffffffffffffffffff1661116b576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61016054835160808501516040517f3fdb071d000000000000000000000000000000000000000000000000000000008152600481019290925273ffffffffffffffffffffffffffffffffffffffff908116602483015290911690633fdb071d90604401600060405180830381600087803b1580156111e857600080fd5b505af11580156111fc573d6000803e3d6000fd5b505050505b60c083015160019073ffffffffffffffffffffffffffffffffffffffff1615801590611231575060c08401513b15155b156112fa5760c0840151602085015160408087015160e088015160608901516101208a01516101008b015194517fcc54dc9500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169663cc54dc95966112b396919591949193919260040161494c565b6020604051808303816000875af11580156112d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f691906149bb565b9150505b600161016685606001516040516113119190614316565b908152602001604051809103902060008660200151815260200190815260200160002060006101000a81548160ff0219169083151502179055506101626000815461135b90614729565b9091555080611443576101625484602001517f3bf9ad3ae3a3a7c22a8cb63b259bcf1abc195a223b499b4c8e884981d6154839866060015161015f878960e0015160006040516020016113b990602080825260009082015260400190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290526113f592916020016149d8565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905261143495949392916000906149f3565b60405180910390a35050611674565b6060600085610140015161156c5785610100015173ffffffffffffffffffffffffffffffffffffffff16631aa6485a60e01b8760e00151886101200151896060015160405160240161149793929190614a6a565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516115209190614316565b6000604051808303816000865af19150503d806000811461155d576040519150601f19603f3d011682016040523d82523d6000602084013e611562565b606091505b50925090506115e1565b85610100015173ffffffffffffffffffffffffffffffffffffffff1686610120015160405161159b9190614316565b600060405180830381855afa9150503d80600081146115d6576040519150601f19603f3d011682016040523d82523d6000602084013e6115db565b606091505b50925090505b801580156115f15750620124f85a105b15611628576040517f9e82ca7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101625486602001517f3bf9ad3ae3a3a7c22a8cb63b259bcf1abc195a223b499b4c8e884981d6154839886060015161015f898b60e001518888604051610b22969594939291906149f3565b610b39600161012d55565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163003611744576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610c0b565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166117b97f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff161461185c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610c0b565b611865826126fe565b610c1e82826001612709565b600054610100900460ff16158080156118915750600054600160ff909116105b806118ab5750303b1580156118ab575060005460ff166001145b611937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610c0b565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561199557600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b825184511415806119a557508351155b156119dc576040517fc6617b7b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611a0060405180606001604052806060815260200160608152602001600081525090565b50604080516060810182528581526020810185905267ffffffffffffffff84168183015290517f37c7b5a600000000000000000000000000000000000000000000000000000000815273ac589f48f94134db8671acd31f4da55ce43e318c906337c7b5a690611a73908490600401614aa3565b60006040518083038186803b158015611a8b57600080fd5b505af4158015611a9f573d6000803e3d6000fd5b505050506000611aae82612908565b9050611ab8612cdf565b611ac0612d7e565b611ac8612e15565b611ad360003361254f565b611afd7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb0783361254f565b611b277f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c3361254f565b61015f611b348882614bc8565b50600161016281905567ffffffffffffffff85166101638190556101648390556101618290556040517f20d5dcc846f7451afb9c8dc6dbf5f2242d04549ae17eb976f19b36cb4d7e165690611b909061015f908b908b90614d6d565b60405180910390a350508015610b3957600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050505050565b60003073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614611cca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c0b565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b6000611cfa81612545565b73ffffffffffffffffffffffffffffffffffffffff8216611d47576040517fecba735200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61016080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fa61fe9500102ba95e70ba9796789006b4719448a4ebc364e6c2c943d5d63d18f9060200160405180910390a15050565b6000611dcc6123ed565b61016554341015611e09576040517f4cf59ae600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8915611f0c578888604051611e1f929190614da6565b6040519081900390207fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47003611e80576040517f440afe4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610160546040517f6e553f65000000000000000000000000000000000000000000000000000000008152600481018c905233602482015273ffffffffffffffffffffffffffffffffffffffff90911690636e553f6590604401600060405180830381600087803b158015611ef357600080fd5b505af1158015611f07573d6000803e3d6000fd5b505050505b61016260008154611f1c90614729565b90915550611f328b8b89898d8d8b8b8b8b612eb4565b50610162549a9950505050505050505050565b7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c611f6f81612545565b610e24612f13565b61015f8054611f8590614332565b80601f0160208091040260200160405190810160405280929190818152602001828054611fb190614332565b8015611ffe5780601f10611fd357610100808354040283529160200191611ffe565b820191906000526020600020905b815481529060010190602001808311611fe157829003601f168201915b505050505081565b60008281526097602052604090206001015461202181612545565b610b658383612643565b600061203681612545565b73ffffffffffffffffffffffffffffffffffffffff8516156121ba5760405173ffffffffffffffffffffffffffffffffffffffff858116602483015260448201849052600091908716908590606401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052516121069190614316565b60006040518083038160008787f1925050503d8060008114612144576040519150601f19603f3d011682016040523d82523d6000602084013e612149565b606091505b50509050806121b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4661696c656420746f2073656e6420546f6b656e7321000000000000000000006044820152606401610c0b565b50610b39565b60008473ffffffffffffffffffffffffffffffffffffffff168484604051600060405180830381858888f193505050503d8060008114612216576040519150601f19603f3d011682016040523d82523d6000602084013e61221b565b606091505b5050905080612286576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4661696c656420746f2073656e642045746821000000000000000000000000006044820152606401610c0b565b505050505050565b7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb0786122b881612545565b678ac7230489e8000082106122cf576122cf614db6565b6101655460408051918252602082018490527f4fc4e10a6b18b18a9b637c4c543c7bc1d0759966d577ac6a9f4bbfaf678862f4910160405180910390a15061016555565b600061231d6123ed565b6101655434101561235a576040517f4cf59ae600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610162805490600061236b83614729565b9190505550610162547f1ff6cbf099d2cd90494426a312eae3d52a88116b0ee9f37e074072a79a2334893361015f856040516123a993929190614de5565b60405180910390a250610162545b919050565b7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb0786123e681612545565b5061016155565b60335460ff161561245a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610c0b565b565b600261012d54036124c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c0b565b600261012d55565b610164546124e1610eca86614669565b14612518576040517f723a340300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80516020820120600061252a8261298e565b90506122868686868463aaaaaaab6129f5565b600161012d55565b610e248133612f6e565b600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610c1e57600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556125e53390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610c1e57600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610c1e81612545565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561273c57610b6583613028565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156127c1575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526127be91810190614e26565b60015b61284d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610c0b565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81146128fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610c0b565b50610b65838383613132565b6000807f636865636b706f696e740000000000000000000000000000000000000000000060001b8360400151846000015185602001516040516020016129519493929190614e3f565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209392505050565b60006040518060400160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250826040516020016129d8929190614e7b565b604051602081830303815290604052805190602001209050919050565b6000805b612a038780614761565b90508167ffffffffffffffff161015612c005785858267ffffffffffffffff16818110612a3257612a32614e9d565b9050602002810190612a449190614ecc565b9050604114612a7f576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600086868367ffffffffffffffff16818110612a9d57612a9d614e9d565b9050602002810190612aaf9190614ecc565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052506020850151604086015160608701519697509095909450901a9150508015612be957612b46612b0e8c80614761565b8767ffffffffffffffff16818110612b2857612b28614e9d565b9050602002016020810190612b3d9190613c7c565b89858585613157565b612b7c576040517f8baa579f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612b8960208c018c614761565b8667ffffffffffffffff16818110612ba357612ba3614e9d565b9050602002016020810190612bb89190614f31565b612bc29087614f4c565b95508667ffffffffffffffff168667ffffffffffffffff161115612be95750505050612c00565b505050508080612bf890614f74565b9150506129f9565b508167ffffffffffffffff168167ffffffffffffffff1611612286576040517ffc86a67100000000000000000000000000000000000000000000000000000000815267ffffffffffffffff808316600483015283166024820152604401610c0b565b612c6a61319e565b603380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b600054610100900460ff16612d76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b61245a61320a565b600054610100900460ff1661245a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b600054610100900460ff16612eac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b61245a6132a1565b610162547ffe97fc293d7232e604aad58a3d02e21ee253fa0462586ea83bf3d6a84d987a6a8b8b3361015f8d8d8d8d8d8d8d8d604051612eff9c9b9a99989796959493929190614fe4565b60405180910390a250505050505050505050565b612f1b6123ed565b603380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612cb53390565b600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610c1e57612fae81613362565b612fb9836020613381565b604051602001612fca929190615087565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610c0b91600401614288565b73ffffffffffffffffffffffffffffffffffffffff81163b6130cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610c0b565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b61313b836135cb565b6000825111806131485750805b15610b6557610fc38383613618565b60006131658585858561363d565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614905095945050505050565b60335460ff1661245a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610c0b565b600054610100900460ff1661253d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b600054610100900460ff16613338576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b603380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b606061076b73ffffffffffffffffffffffffffffffffffffffff831660145b60606000613390836002615108565b61339b90600261511f565b67ffffffffffffffff8111156133b3576133b3613959565b6040519080825280601f01601f1916602001820160405280156133dd576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061341457613414614e9d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061347757613477614e9d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006134b3846002615108565b6134be90600161511f565b90505b600181111561355b577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106134ff576134ff614e9d565b1a60f81b82828151811061351557613515614e9d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c9361355481615132565b90506134c1565b5083156135c4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610c0b565b9392505050565b6135d481613028565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606135c483836040518060600160405280602781526020016151686027913961374f565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613699576040517f40c1e74800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160008082526020820180845288905260ff851692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156136ed573d6000803e3d6000fd5b5050506020604051035191508173ffffffffffffffffffffffffffffffffffffffff1603613747576040517f629289a100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516137799190614316565b600060405180830381855af49150503d80600081146137b4576040519150601f19603f3d011682016040523d82523d6000602084013e6137b9565b606091505b50915091506137ca868383876137d4565b9695505050505050565b6060831561386a5782516000036138635773ffffffffffffffffffffffffffffffffffffffff85163b613863576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c0b565b5081613747565b613747838381511561387f5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0b9190614288565b6000602082840312156138c557600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146135c457600080fd5b60006060828403121561390757600080fd5b50919050565b60008083601f84011261391f57600080fd5b50813567ffffffffffffffff81111561393757600080fd5b6020830191508360208260051b850101111561395257600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160c0810167ffffffffffffffff811182821017156139ab576139ab613959565b60405290565b604051610160810167ffffffffffffffff811182821017156139ab576139ab613959565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613a1c57613a1c613959565b604052919050565b600082601f830112613a3557600080fd5b813567ffffffffffffffff811115613a4f57613a4f613959565b613a8060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016139d5565b818152846020838601011115613a9557600080fd5b816020850160208301376000918101602001919091529392505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610e2457600080fd5b80356123b781613ab2565b8015158114610e2457600080fd5b80356123b781613adf565b600080600080600060808688031215613b1057600080fd5b853567ffffffffffffffff80821115613b2857600080fd5b613b3489838a016138f5565b96506020880135915080821115613b4a57600080fd5b613b5689838a0161390d565b90965094506040880135915080821115613b6f57600080fd5b9087019060c0828a031215613b8357600080fd5b613b8b613988565b8235815260208301356020820152604083013582811115613bab57600080fd5b613bb78b828601613a24565b604083015250613bc960608401613ad4565b6060820152608083013582811115613be057600080fd5b613bec8b828601613a24565b608083015250613bfe60a08401613aed565b60a082015293506060880135915080821115613c1957600080fd5b50613c2688828901613a24565b9150509295509295909350565b600060208284031215613c4557600080fd5b5035919050565b60008060408385031215613c5f57600080fd5b823591506020830135613c7181613ab2565b809150509250929050565b600060208284031215613c8e57600080fd5b81356135c481613ab2565b60008060008060608587031215613caf57600080fd5b843567ffffffffffffffff80821115613cc757600080fd5b613cd3888389016138f5565b95506020870135915080821115613ce957600080fd5b613cf5888389016138f5565b94506040870135915080821115613d0b57600080fd5b50613d188782880161390d565b95989497509550505050565b600080600080600060808688031215613d3c57600080fd5b853567ffffffffffffffff80821115613d5457600080fd5b613d6089838a016138f5565b96506020880135915080821115613d7657600080fd5b613d8289838a0161390d565b90965094506040880135915080821115613d9b57600080fd5b90870190610160828a031215613db057600080fd5b613db86139b1565b823581526020830135602082015260408301356040820152606083013582811115613de257600080fd5b613dee8b828601613a24565b606083015250613e0060808401613ad4565b608082015260a083013582811115613e1757600080fd5b613e238b828601613a24565b60a083015250613e3560c08401613ad4565b60c082015260e083013582811115613e4c57600080fd5b613e588b828601613a24565b60e083015250610100613e6c818501613ad4565b908201526101208381013583811115613e8457600080fd5b613e908c828701613a24565b828401525050610140613ea4818501613aed565b9082015293506060880135915080821115613c1957600080fd5b60008060408385031215613ed157600080fd5b8235613edc81613ab2565b9150602083013567ffffffffffffffff811115613ef857600080fd5b613f0485828601613a24565b9150509250929050565b600067ffffffffffffffff821115613f2857613f28613959565b5060051b60200190565b600082601f830112613f4357600080fd5b81356020613f58613f5383613f0e565b6139d5565b82815260059290921b84018101918181019086841115613f7757600080fd5b8286015b84811015613f9b578035613f8e81613ab2565b8352918301918301613f7b565b509695505050505050565b803567ffffffffffffffff811681146123b757600080fd5b600082601f830112613fcf57600080fd5b81356020613fdf613f5383613f0e565b82815260059290921b84018101918181019086841115613ffe57600080fd5b8286015b84811015613f9b5761401381613fa6565b8352918301918301614002565b6000806000806080858703121561403657600080fd5b843567ffffffffffffffff8082111561404e57600080fd5b61405a88838901613a24565b9550602087013591508082111561407057600080fd5b61407c88838901613f32565b9450604087013591508082111561409257600080fd5b5061409f87828801613fbe565b9250506140ae60608601613fa6565b905092959194509250565b600080604083850312156140cc57600080fd5b823567ffffffffffffffff8111156140e357600080fd5b6140ef85828601613a24565b95602094909401359450505050565b60008083601f84011261411057600080fd5b50813567ffffffffffffffff81111561412857600080fd5b60208301915083602082850101111561395257600080fd5b60008060008060008060008060008060c08b8d03121561415f57600080fd5b8a35995060208b0135985060408b013567ffffffffffffffff8082111561418557600080fd5b6141918e838f016140fe565b909a50985060608d01359150808211156141aa57600080fd5b6141b68e838f016140fe565b909850965060808d01359150808211156141cf57600080fd5b6141db8e838f016140fe565b909650945060a08d01359150808211156141f457600080fd5b506142018d828e016140fe565b915080935050809150509295989b9194979a5092959850565b60005b8381101561423557818101518382015260200161421d565b50506000910152565b6000815180845261425681602086016020860161421a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006135c4602083018461423e565b600080600080608085870312156142b157600080fd5b84356142bc81613ab2565b935060208501356142cc81613ab2565b93969395505050506040820135916060013590565b6000602082840312156142f357600080fd5b813567ffffffffffffffff81111561430a57600080fd5b61374784828501613a24565b6000825161432881846020870161421a565b9190910192915050565b600181811c9082168061434657607f821691505b602082108103613907577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000815461438c81614332565b8085526020600183811680156143a957600181146143e15761440f565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008516838901528284151560051b890101955061440f565b866000528260002060005b858110156144075781548a82018601529083019084016143ec565b890184019650505b505050505092915050565b60006101008a83528060208401526144348184018b61437f565b90508860408401528760608401528281036080840152614454818861423e565b905073ffffffffffffffffffffffffffffffffffffffff861660a084015282810360c0840152614484818661423e565b91505082151560e08301529998505050505050505050565b83815282151560208201526060604082015260006144bd606083018461423e565b95945050505050565b6080815260006144d9608083018761423e565b82810360208401526144eb818761437f565b905082810360408401526144ff818661423e565b915050821515606083015295945050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261454857600080fd5b830160208101925035905067ffffffffffffffff81111561456857600080fd5b8060051b360382131561395257600080fd5b60006060830161458a8384614513565b606086529182905290600090608086015b818310156145d95783356145ae81613ab2565b73ffffffffffffffffffffffffffffffffffffffff168152602093840193600193909301920161459b565b602093506145e984870187614513565b888303868a01528083529350915060009084015b8382101561462c5767ffffffffffffffff61461784613fa6565b168152918401916001919091019084016145fd565b60408701356040890152809550505050505092915050565b604081526000614657604083018561457a565b82810360208401526144bd818561457a565b60006060823603121561467b57600080fd5b6040516060810167ffffffffffffffff828210818311171561469f5761469f613959565b8160405284359150808211156146b457600080fd5b6146c036838701613f32565b835260208501359150808211156146d657600080fd5b506146e336828601613fbe565b602083015250604092830135928101929092525090565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361475a5761475a6146fa565b5060010190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261479657600080fd5b83018035915067ffffffffffffffff8211156147b157600080fd5b6020019150600581901b360382131561395257600080fd5b6060815260006147dc606083018861437f565b8281036020848101919091528682528791810160005b8881101561482d57833561480581613ab2565b73ffffffffffffffffffffffffffffffffffffffff16825292820192908201906001016147f2565b508481036040860152858152810191508560005b8681101561486e5767ffffffffffffffff61485b83613fa6565b1684529282019290820190600101614841565b50919998505050505050505050565b60006101808e83528d60208401528c60408401528b60608401528060808401526148a98184018c61423e565b905073ffffffffffffffffffffffffffffffffffffffff808b1660a085015283820360c08501526148da828b61437f565b90891660e085015283810361010085015290506148f7818861423e565b73ffffffffffffffffffffffffffffffffffffffff87166101208501529050828103610140840152614929818661423e565b91505061493b61016083018415159052565b9d9c50505050505050505050505050565b86815285602082015260c06040820152600061496b60c083018761423e565b828103606084015261497d818761423e565b90508281036080840152614991818661423e565b91505073ffffffffffffffffffffffffffffffffffffffff831660a0830152979650505050505050565b6000602082840312156149cd57600080fd5b81516135c481613adf565b8215158152604060208201526000613747604083018461423e565b60c081526000614a0660c083018961423e565b8281036020840152614a18818961437f565b90508281036040840152614a2c818861423e565b90508281036060840152614a40818761423e565b90508281036080840152614a54818661423e565b91505082151560a0830152979650505050505050565b606081526000614a7d606083018661423e565b8281036020840152614a8f818661423e565b905082810360408401526137ca818561423e565b6020808252825160608383015280516080840181905260009291820190839060a08601905b80831015614afe57835173ffffffffffffffffffffffffffffffffffffffff168252928401926001929092019190840190614ac8565b50868401518682037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00160408801528051808352908501935090840191506000905b80821015614b6a57835167ffffffffffffffff168352928401929184019160019190910190614b40565b50506040860151606086015280935050505092915050565b601f821115610b6557600081815260208120601f850160051c81016020861015614ba95750805b601f850160051c820191505b8181101561228657828155600101614bb5565b815167ffffffffffffffff811115614be257614be2613959565b614bf681614bf08454614332565b84614b82565b602080601f831160018114614c495760008415614c135750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555612286565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015614c9657888601518255948401946001909101908401614c77565b5085821015614cd257878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b600081518084526020808501945080840160005b83811015614d2857815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101614cf6565b509495945050505050565b600081518084526020808501945080840160005b83811015614d2857815167ffffffffffffffff1687529582019590820190600101614d47565b606081526000614d80606083018661437f565b8281036020840152614d928186614ce2565b905082810360408401526137ca8185614d33565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff84168152606060208201526000614e14606083018561437f565b82810360408401526137ca818561423e565b600060208284031215614e3857600080fd5b5051919050565b848152836020820152608060408201526000614e5e6080830185614ce2565b8281036060840152614e708185614d33565b979650505050505050565b60008351614e8d81846020880161421a565b9190910191825250602001919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112614f0157600080fd5b83018035915067ffffffffffffffff821115614f1c57600080fd5b60200191503681900382131561395257600080fd5b600060208284031215614f4357600080fd5b6135c482613fa6565b67ffffffffffffffff818116838216019080821115614f6d57614f6d6146fa565b5092915050565b600067ffffffffffffffff808316818103614f9157614f916146fa565b6001019392505050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60006101008e83528d602084015273ffffffffffffffffffffffffffffffffffffffff8d1660408401528060608401526150208184018d61437f565b90508281036080840152615035818b8d614f9b565b905082810360a084015261504a81898b614f9b565b905082810360c084015261505f818789614f9b565b905082810360e0840152615074818587614f9b565b9f9e505050505050505050505050505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516150bf81601785016020880161421a565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516150fc81602884016020880161421a565b01602801949350505050565b808202811582820484141761076b5761076b6146fa565b8082018082111561076b5761076b6146fa565b600081615141576151416146fa565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a164736f6c6343000815000a
Deployed Bytecode
0x6080604052600436106102195760003560e01c80637a40d0f71161011d578063a707d6b8116100b0578063e88fc81d1161007f578063ef15cbda11610064578063ef15cbda14610652578063f3a0ce4114610665578063fbfa77cf1461068557600080fd5b8063e88fc81d14610612578063ea76f6d71461063257600080fd5b8063a707d6b814610573578063d547741f1461058a578063d9dc8694146105aa578063db618e2a146105de57600080fd5b80639a8a0592116100ec5780639a8a0592146104f45780639d888e8614610516578063a0436a411461052d578063a217fddf1461055e57600080fd5b80637a40d0f71461042d5780637bed470a146104795780638456cb591461048c57806391d14854146104a157600080fd5b80633bcced29116101b05780634f1ef2861161017f57806352d1902d1161016457806352d1902d146103e05780635c975abb146103f55780636817031b1461040d57600080fd5b80634f1ef286146103ad57806351b6ac3f146103c057600080fd5b80633bcced29146103415780633f4ba83a1461036157806342fb207c1461037657806344bdf5a71461038d57600080fd5b8063248a9ca3116101ec578063248a9ca3146102b15780632f2ff15d146102e157806336568abe146103015780633659cfe61461032157600080fd5b806301ffc9a71461021e57806305cf22fc146102535780631c3e6ee6146102785780632205643a1461028f575b600080fd5b34801561022a57600080fd5b5061023e6102393660046138b3565b6106d8565b60405190151581526020015b60405180910390f35b34801561025f57600080fd5b5061026a6101645481565b60405190815260200161024a565b34801561028457600080fd5b5061026a6101625481565b34801561029b57600080fd5b506102af6102aa366004613af8565b610771565b005b3480156102bd57600080fd5b5061026a6102cc366004613c33565b60009081526097602052604090206001015490565b3480156102ed57600080fd5b506102af6102fc366004613c4c565b610b40565b34801561030d57600080fd5b506102af61031c366004613c4c565b610b6a565b34801561032d57600080fd5b506102af61033c366004613c7c565b610c22565b34801561034d57600080fd5b506102af61035c366004613c99565b610e27565b34801561036d57600080fd5b506102af610fc9565b34801561038257600080fd5b5061026a6101635481565b34801561039957600080fd5b506102af6103a8366004613d24565b610ffb565b6102af6103bb366004613ebe565b61167f565b3480156103cc57600080fd5b506102af6103db366004614020565b611871565b3480156103ec57600080fd5b5061026a611c03565b34801561040157600080fd5b5060335460ff1661023e565b34801561041957600080fd5b506102af610428366004613c7c565b611cef565b34801561043957600080fd5b5061023e6104483660046140b9565b8151602081840181018051610166825292820194820194909420919093529091526000908152604090205460ff1681565b61026a610487366004614140565b611dc2565b34801561049857600080fd5b506102af611f45565b3480156104ad57600080fd5b5061023e6104bc366004613c4c565b600091825260976020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561050057600080fd5b50610509611f77565b60405161024a9190614288565b34801561052257600080fd5b5061026a6101615481565b34801561053957600080fd5b5061023e610548366004613c33565b6101676020526000908152604090205460ff1681565b34801561056a57600080fd5b5061026a600081565b34801561057f57600080fd5b5061026a6101655481565b34801561059657600080fd5b506102af6105a5366004613c4c565b612006565b3480156105b657600080fd5b5061026a7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c81565b3480156105ea57600080fd5b5061026a7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb07881565b34801561061e57600080fd5b506102af61062d36600461429b565b61202b565b34801561063e57600080fd5b506102af61064d366004613c33565b61228e565b61026a6106603660046142e1565b612313565b34801561067157600080fd5b506102af610680366004613c33565b6123bc565b34801561069157600080fd5b50610160546106b39073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161024a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061076b57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b6107796123ed565b61078161245c565b81516000908152610167602052604090205460ff1615156001036107d1576040517fe4bb7a0400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61016682604001516040516107e69190614316565b9081526040805160209281900383019020848301516000908152925290205460ff161515600103610843576040517f92539f4600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60007f6941636b0000000000000000000000000000000000000000000000000000000060001b61015f846000015185602001518660400151876060015188608001518960a001516040516020016108a198979695949392919061441a565b60405160208183030381529060405290506108be868686846124d1565b8251600090815261016760205260409081902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660019081179091558185015191519091610166916109139190614316565b90815260408051602092819003830190208683015160009081529252812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016921515929092179091556101628054600101908190556060850151909190819073ffffffffffffffffffffffffffffffffffffffff165a875160a089015160808a01516040517fa4e2128800000000000000000000000000000000000000000000000000000000936109cd939092909160240161449c565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051610a569190614316565b60006040518083038160008787f1925050503d8060008114610a94576040519150601f19603f3d011682016040523d82523d6000602084013e610a99565b606091505b509150915081158015610aae5750620124f85a105b15610ae5576040517f9e82ca7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8560000151837f21a2de7d1ff2cd4fe0ffece047122598d9d5ef15a7aecff28f73c7deae9d64db8761015f8587604051610b2294939291906144c6565b60405180910390a350505050610b39600161012d55565b5050505050565b600082815260976020526040902060010154610b5b81612545565b610b65838361254f565b505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610c14576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b610c1e8282612643565b5050565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000086dfc31d9cb3280ee1eb1096caa9fc66299af973163003610ce7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610c0b565b7f00000000000000000000000086dfc31d9cb3280ee1eb1096caa9fc66299af97373ffffffffffffffffffffffffffffffffffffffff16610d5c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610dff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610c0b565b610e08816126fe565b60408051600080825260208201909252610e2491839190612709565b50565b610e2f6123ed565b610e3761245c565b6040517fa0c8e6a900000000000000000000000000000000000000000000000000000000815273ac589f48f94134db8671acd31f4da55ce43e318c9063a0c8e6a990610e899087908790600401614644565b60006040518083038186803b158015610ea157600080fd5b505af4158015610eb5573d6000803e3d6000fd5b5050505061016454610ecf84610eca90614669565b612908565b14610f06576040517f723a340300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610f14610eca86614669565b90506000610f218261298e565b9050610f348585858463aaaaaaab6129f5565b6101648290556040860135610163556101628054906000610f5483614729565b90915550506101625460408701357f20d5dcc846f7451afb9c8dc6dbf5f2242d04549ae17eb976f19b36cb4d7e165661015f610f908a80614761565b610f9d60208d018d614761565b604051610fae9594939291906147c9565b60405180910390a35050610fc3600161012d55565b50505050565b7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c610ff381612545565b610e24612c62565b6110036123ed565b61100b61245c565b60007f695265636569766500000000000000000000000000000000000000000000000060001b8360000151846020015185604001518660600151876080015161015f8960c001518a60e001518b61010001518c61012001518d61014001516040516020016110849c9b9a9998979695949392919061487d565b60405160208183030381529060405290506110a1868686846124d1565b61016683606001516040516110b69190614316565b9081526040805160209281900383019020858301516000908152925290205460ff161515600103611113576040517fe4bb7a0400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82511561120157608083015173ffffffffffffffffffffffffffffffffffffffff1661116b576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61016054835160808501516040517f3fdb071d000000000000000000000000000000000000000000000000000000008152600481019290925273ffffffffffffffffffffffffffffffffffffffff908116602483015290911690633fdb071d90604401600060405180830381600087803b1580156111e857600080fd5b505af11580156111fc573d6000803e3d6000fd5b505050505b60c083015160019073ffffffffffffffffffffffffffffffffffffffff1615801590611231575060c08401513b15155b156112fa5760c0840151602085015160408087015160e088015160608901516101208a01516101008b015194517fcc54dc9500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169663cc54dc95966112b396919591949193919260040161494c565b6020604051808303816000875af11580156112d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f691906149bb565b9150505b600161016685606001516040516113119190614316565b908152602001604051809103902060008660200151815260200190815260200160002060006101000a81548160ff0219169083151502179055506101626000815461135b90614729565b9091555080611443576101625484602001517f3bf9ad3ae3a3a7c22a8cb63b259bcf1abc195a223b499b4c8e884981d6154839866060015161015f878960e0015160006040516020016113b990602080825260009082015260400190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290526113f592916020016149d8565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905261143495949392916000906149f3565b60405180910390a35050611674565b6060600085610140015161156c5785610100015173ffffffffffffffffffffffffffffffffffffffff16631aa6485a60e01b8760e00151886101200151896060015160405160240161149793929190614a6a565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516115209190614316565b6000604051808303816000865af19150503d806000811461155d576040519150601f19603f3d011682016040523d82523d6000602084013e611562565b606091505b50925090506115e1565b85610100015173ffffffffffffffffffffffffffffffffffffffff1686610120015160405161159b9190614316565b600060405180830381855afa9150503d80600081146115d6576040519150601f19603f3d011682016040523d82523d6000602084013e6115db565b606091505b50925090505b801580156115f15750620124f85a105b15611628576040517f9e82ca7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101625486602001517f3bf9ad3ae3a3a7c22a8cb63b259bcf1abc195a223b499b4c8e884981d6154839886060015161015f898b60e001518888604051610b22969594939291906149f3565b610b39600161012d55565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000086dfc31d9cb3280ee1eb1096caa9fc66299af973163003611744576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610c0b565b7f00000000000000000000000086dfc31d9cb3280ee1eb1096caa9fc66299af97373ffffffffffffffffffffffffffffffffffffffff166117b97f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff161461185c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610c0b565b611865826126fe565b610c1e82826001612709565b600054610100900460ff16158080156118915750600054600160ff909116105b806118ab5750303b1580156118ab575060005460ff166001145b611937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610c0b565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561199557600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b825184511415806119a557508351155b156119dc576040517fc6617b7b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611a0060405180606001604052806060815260200160608152602001600081525090565b50604080516060810182528581526020810185905267ffffffffffffffff84168183015290517f37c7b5a600000000000000000000000000000000000000000000000000000000815273ac589f48f94134db8671acd31f4da55ce43e318c906337c7b5a690611a73908490600401614aa3565b60006040518083038186803b158015611a8b57600080fd5b505af4158015611a9f573d6000803e3d6000fd5b505050506000611aae82612908565b9050611ab8612cdf565b611ac0612d7e565b611ac8612e15565b611ad360003361254f565b611afd7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb0783361254f565b611b277f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c3361254f565b61015f611b348882614bc8565b50600161016281905567ffffffffffffffff85166101638190556101648390556101618290556040517f20d5dcc846f7451afb9c8dc6dbf5f2242d04549ae17eb976f19b36cb4d7e165690611b909061015f908b908b90614d6d565b60405180910390a350508015610b3957600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050505050565b60003073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000086dfc31d9cb3280ee1eb1096caa9fc66299af9731614611cca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c0b565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b6000611cfa81612545565b73ffffffffffffffffffffffffffffffffffffffff8216611d47576040517fecba735200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61016080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fa61fe9500102ba95e70ba9796789006b4719448a4ebc364e6c2c943d5d63d18f9060200160405180910390a15050565b6000611dcc6123ed565b61016554341015611e09576040517f4cf59ae600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8915611f0c578888604051611e1f929190614da6565b6040519081900390207fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47003611e80576040517f440afe4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610160546040517f6e553f65000000000000000000000000000000000000000000000000000000008152600481018c905233602482015273ffffffffffffffffffffffffffffffffffffffff90911690636e553f6590604401600060405180830381600087803b158015611ef357600080fd5b505af1158015611f07573d6000803e3d6000fd5b505050505b61016260008154611f1c90614729565b90915550611f328b8b89898d8d8b8b8b8b612eb4565b50610162549a9950505050505050505050565b7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c611f6f81612545565b610e24612f13565b61015f8054611f8590614332565b80601f0160208091040260200160405190810160405280929190818152602001828054611fb190614332565b8015611ffe5780601f10611fd357610100808354040283529160200191611ffe565b820191906000526020600020905b815481529060010190602001808311611fe157829003601f168201915b505050505081565b60008281526097602052604090206001015461202181612545565b610b658383612643565b600061203681612545565b73ffffffffffffffffffffffffffffffffffffffff8516156121ba5760405173ffffffffffffffffffffffffffffffffffffffff858116602483015260448201849052600091908716908590606401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052516121069190614316565b60006040518083038160008787f1925050503d8060008114612144576040519150601f19603f3d011682016040523d82523d6000602084013e612149565b606091505b50509050806121b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4661696c656420746f2073656e6420546f6b656e7321000000000000000000006044820152606401610c0b565b50610b39565b60008473ffffffffffffffffffffffffffffffffffffffff168484604051600060405180830381858888f193505050503d8060008114612216576040519150601f19603f3d011682016040523d82523d6000602084013e61221b565b606091505b5050905080612286576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4661696c656420746f2073656e642045746821000000000000000000000000006044820152606401610c0b565b505050505050565b7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb0786122b881612545565b678ac7230489e8000082106122cf576122cf614db6565b6101655460408051918252602082018490527f4fc4e10a6b18b18a9b637c4c543c7bc1d0759966d577ac6a9f4bbfaf678862f4910160405180910390a15061016555565b600061231d6123ed565b6101655434101561235a576040517f4cf59ae600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610162805490600061236b83614729565b9190505550610162547f1ff6cbf099d2cd90494426a312eae3d52a88116b0ee9f37e074072a79a2334893361015f856040516123a993929190614de5565b60405180910390a250610162545b919050565b7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb0786123e681612545565b5061016155565b60335460ff161561245a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610c0b565b565b600261012d54036124c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c0b565b600261012d55565b610164546124e1610eca86614669565b14612518576040517f723a340300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80516020820120600061252a8261298e565b90506122868686868463aaaaaaab6129f5565b600161012d55565b610e248133612f6e565b600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610c1e57600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556125e53390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610c1e57600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610c1e81612545565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561273c57610b6583613028565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156127c1575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526127be91810190614e26565b60015b61284d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610c0b565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81146128fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610c0b565b50610b65838383613132565b6000807f636865636b706f696e740000000000000000000000000000000000000000000060001b8360400151846000015185602001516040516020016129519493929190614e3f565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209392505050565b60006040518060400160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250826040516020016129d8929190614e7b565b604051602081830303815290604052805190602001209050919050565b6000805b612a038780614761565b90508167ffffffffffffffff161015612c005785858267ffffffffffffffff16818110612a3257612a32614e9d565b9050602002810190612a449190614ecc565b9050604114612a7f576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600086868367ffffffffffffffff16818110612a9d57612a9d614e9d565b9050602002810190612aaf9190614ecc565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052506020850151604086015160608701519697509095909450901a9150508015612be957612b46612b0e8c80614761565b8767ffffffffffffffff16818110612b2857612b28614e9d565b9050602002016020810190612b3d9190613c7c565b89858585613157565b612b7c576040517f8baa579f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612b8960208c018c614761565b8667ffffffffffffffff16818110612ba357612ba3614e9d565b9050602002016020810190612bb89190614f31565b612bc29087614f4c565b95508667ffffffffffffffff168667ffffffffffffffff161115612be95750505050612c00565b505050508080612bf890614f74565b9150506129f9565b508167ffffffffffffffff168167ffffffffffffffff1611612286576040517ffc86a67100000000000000000000000000000000000000000000000000000000815267ffffffffffffffff808316600483015283166024820152604401610c0b565b612c6a61319e565b603380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b600054610100900460ff16612d76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b61245a61320a565b600054610100900460ff1661245a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b600054610100900460ff16612eac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b61245a6132a1565b610162547ffe97fc293d7232e604aad58a3d02e21ee253fa0462586ea83bf3d6a84d987a6a8b8b3361015f8d8d8d8d8d8d8d8d604051612eff9c9b9a99989796959493929190614fe4565b60405180910390a250505050505050505050565b612f1b6123ed565b603380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612cb53390565b600082815260976020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610c1e57612fae81613362565b612fb9836020613381565b604051602001612fca929190615087565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610c0b91600401614288565b73ffffffffffffffffffffffffffffffffffffffff81163b6130cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610c0b565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b61313b836135cb565b6000825111806131485750805b15610b6557610fc38383613618565b60006131658585858561363d565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614905095945050505050565b60335460ff1661245a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610c0b565b600054610100900460ff1661253d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b600054610100900460ff16613338576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c0b565b603380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b606061076b73ffffffffffffffffffffffffffffffffffffffff831660145b60606000613390836002615108565b61339b90600261511f565b67ffffffffffffffff8111156133b3576133b3613959565b6040519080825280601f01601f1916602001820160405280156133dd576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061341457613414614e9d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061347757613477614e9d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006134b3846002615108565b6134be90600161511f565b90505b600181111561355b577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106134ff576134ff614e9d565b1a60f81b82828151811061351557613515614e9d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c9361355481615132565b90506134c1565b5083156135c4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610c0b565b9392505050565b6135d481613028565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606135c483836040518060600160405280602781526020016151686027913961374f565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613699576040517f40c1e74800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160008082526020820180845288905260ff851692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156136ed573d6000803e3d6000fd5b5050506020604051035191508173ffffffffffffffffffffffffffffffffffffffff1603613747576040517f629289a100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516137799190614316565b600060405180830381855af49150503d80600081146137b4576040519150601f19603f3d011682016040523d82523d6000602084013e6137b9565b606091505b50915091506137ca868383876137d4565b9695505050505050565b6060831561386a5782516000036138635773ffffffffffffffffffffffffffffffffffffffff85163b613863576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c0b565b5081613747565b613747838381511561387f5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0b9190614288565b6000602082840312156138c557600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146135c457600080fd5b60006060828403121561390757600080fd5b50919050565b60008083601f84011261391f57600080fd5b50813567ffffffffffffffff81111561393757600080fd5b6020830191508360208260051b850101111561395257600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160c0810167ffffffffffffffff811182821017156139ab576139ab613959565b60405290565b604051610160810167ffffffffffffffff811182821017156139ab576139ab613959565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613a1c57613a1c613959565b604052919050565b600082601f830112613a3557600080fd5b813567ffffffffffffffff811115613a4f57613a4f613959565b613a8060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016139d5565b818152846020838601011115613a9557600080fd5b816020850160208301376000918101602001919091529392505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610e2457600080fd5b80356123b781613ab2565b8015158114610e2457600080fd5b80356123b781613adf565b600080600080600060808688031215613b1057600080fd5b853567ffffffffffffffff80821115613b2857600080fd5b613b3489838a016138f5565b96506020880135915080821115613b4a57600080fd5b613b5689838a0161390d565b90965094506040880135915080821115613b6f57600080fd5b9087019060c0828a031215613b8357600080fd5b613b8b613988565b8235815260208301356020820152604083013582811115613bab57600080fd5b613bb78b828601613a24565b604083015250613bc960608401613ad4565b6060820152608083013582811115613be057600080fd5b613bec8b828601613a24565b608083015250613bfe60a08401613aed565b60a082015293506060880135915080821115613c1957600080fd5b50613c2688828901613a24565b9150509295509295909350565b600060208284031215613c4557600080fd5b5035919050565b60008060408385031215613c5f57600080fd5b823591506020830135613c7181613ab2565b809150509250929050565b600060208284031215613c8e57600080fd5b81356135c481613ab2565b60008060008060608587031215613caf57600080fd5b843567ffffffffffffffff80821115613cc757600080fd5b613cd3888389016138f5565b95506020870135915080821115613ce957600080fd5b613cf5888389016138f5565b94506040870135915080821115613d0b57600080fd5b50613d188782880161390d565b95989497509550505050565b600080600080600060808688031215613d3c57600080fd5b853567ffffffffffffffff80821115613d5457600080fd5b613d6089838a016138f5565b96506020880135915080821115613d7657600080fd5b613d8289838a0161390d565b90965094506040880135915080821115613d9b57600080fd5b90870190610160828a031215613db057600080fd5b613db86139b1565b823581526020830135602082015260408301356040820152606083013582811115613de257600080fd5b613dee8b828601613a24565b606083015250613e0060808401613ad4565b608082015260a083013582811115613e1757600080fd5b613e238b828601613a24565b60a083015250613e3560c08401613ad4565b60c082015260e083013582811115613e4c57600080fd5b613e588b828601613a24565b60e083015250610100613e6c818501613ad4565b908201526101208381013583811115613e8457600080fd5b613e908c828701613a24565b828401525050610140613ea4818501613aed565b9082015293506060880135915080821115613c1957600080fd5b60008060408385031215613ed157600080fd5b8235613edc81613ab2565b9150602083013567ffffffffffffffff811115613ef857600080fd5b613f0485828601613a24565b9150509250929050565b600067ffffffffffffffff821115613f2857613f28613959565b5060051b60200190565b600082601f830112613f4357600080fd5b81356020613f58613f5383613f0e565b6139d5565b82815260059290921b84018101918181019086841115613f7757600080fd5b8286015b84811015613f9b578035613f8e81613ab2565b8352918301918301613f7b565b509695505050505050565b803567ffffffffffffffff811681146123b757600080fd5b600082601f830112613fcf57600080fd5b81356020613fdf613f5383613f0e565b82815260059290921b84018101918181019086841115613ffe57600080fd5b8286015b84811015613f9b5761401381613fa6565b8352918301918301614002565b6000806000806080858703121561403657600080fd5b843567ffffffffffffffff8082111561404e57600080fd5b61405a88838901613a24565b9550602087013591508082111561407057600080fd5b61407c88838901613f32565b9450604087013591508082111561409257600080fd5b5061409f87828801613fbe565b9250506140ae60608601613fa6565b905092959194509250565b600080604083850312156140cc57600080fd5b823567ffffffffffffffff8111156140e357600080fd5b6140ef85828601613a24565b95602094909401359450505050565b60008083601f84011261411057600080fd5b50813567ffffffffffffffff81111561412857600080fd5b60208301915083602082850101111561395257600080fd5b60008060008060008060008060008060c08b8d03121561415f57600080fd5b8a35995060208b0135985060408b013567ffffffffffffffff8082111561418557600080fd5b6141918e838f016140fe565b909a50985060608d01359150808211156141aa57600080fd5b6141b68e838f016140fe565b909850965060808d01359150808211156141cf57600080fd5b6141db8e838f016140fe565b909650945060a08d01359150808211156141f457600080fd5b506142018d828e016140fe565b915080935050809150509295989b9194979a5092959850565b60005b8381101561423557818101518382015260200161421d565b50506000910152565b6000815180845261425681602086016020860161421a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006135c4602083018461423e565b600080600080608085870312156142b157600080fd5b84356142bc81613ab2565b935060208501356142cc81613ab2565b93969395505050506040820135916060013590565b6000602082840312156142f357600080fd5b813567ffffffffffffffff81111561430a57600080fd5b61374784828501613a24565b6000825161432881846020870161421a565b9190910192915050565b600181811c9082168061434657607f821691505b602082108103613907577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000815461438c81614332565b8085526020600183811680156143a957600181146143e15761440f565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008516838901528284151560051b890101955061440f565b866000528260002060005b858110156144075781548a82018601529083019084016143ec565b890184019650505b505050505092915050565b60006101008a83528060208401526144348184018b61437f565b90508860408401528760608401528281036080840152614454818861423e565b905073ffffffffffffffffffffffffffffffffffffffff861660a084015282810360c0840152614484818661423e565b91505082151560e08301529998505050505050505050565b83815282151560208201526060604082015260006144bd606083018461423e565b95945050505050565b6080815260006144d9608083018761423e565b82810360208401526144eb818761437f565b905082810360408401526144ff818661423e565b915050821515606083015295945050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261454857600080fd5b830160208101925035905067ffffffffffffffff81111561456857600080fd5b8060051b360382131561395257600080fd5b60006060830161458a8384614513565b606086529182905290600090608086015b818310156145d95783356145ae81613ab2565b73ffffffffffffffffffffffffffffffffffffffff168152602093840193600193909301920161459b565b602093506145e984870187614513565b888303868a01528083529350915060009084015b8382101561462c5767ffffffffffffffff61461784613fa6565b168152918401916001919091019084016145fd565b60408701356040890152809550505050505092915050565b604081526000614657604083018561457a565b82810360208401526144bd818561457a565b60006060823603121561467b57600080fd5b6040516060810167ffffffffffffffff828210818311171561469f5761469f613959565b8160405284359150808211156146b457600080fd5b6146c036838701613f32565b835260208501359150808211156146d657600080fd5b506146e336828601613fbe565b602083015250604092830135928101929092525090565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361475a5761475a6146fa565b5060010190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261479657600080fd5b83018035915067ffffffffffffffff8211156147b157600080fd5b6020019150600581901b360382131561395257600080fd5b6060815260006147dc606083018861437f565b8281036020848101919091528682528791810160005b8881101561482d57833561480581613ab2565b73ffffffffffffffffffffffffffffffffffffffff16825292820192908201906001016147f2565b508481036040860152858152810191508560005b8681101561486e5767ffffffffffffffff61485b83613fa6565b1684529282019290820190600101614841565b50919998505050505050505050565b60006101808e83528d60208401528c60408401528b60608401528060808401526148a98184018c61423e565b905073ffffffffffffffffffffffffffffffffffffffff808b1660a085015283820360c08501526148da828b61437f565b90891660e085015283810361010085015290506148f7818861423e565b73ffffffffffffffffffffffffffffffffffffffff87166101208501529050828103610140840152614929818661423e565b91505061493b61016083018415159052565b9d9c50505050505050505050505050565b86815285602082015260c06040820152600061496b60c083018761423e565b828103606084015261497d818761423e565b90508281036080840152614991818661423e565b91505073ffffffffffffffffffffffffffffffffffffffff831660a0830152979650505050505050565b6000602082840312156149cd57600080fd5b81516135c481613adf565b8215158152604060208201526000613747604083018461423e565b60c081526000614a0660c083018961423e565b8281036020840152614a18818961437f565b90508281036040840152614a2c818861423e565b90508281036060840152614a40818761423e565b90508281036080840152614a54818661423e565b91505082151560a0830152979650505050505050565b606081526000614a7d606083018661423e565b8281036020840152614a8f818661423e565b905082810360408401526137ca818561423e565b6020808252825160608383015280516080840181905260009291820190839060a08601905b80831015614afe57835173ffffffffffffffffffffffffffffffffffffffff168252928401926001929092019190840190614ac8565b50868401518682037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00160408801528051808352908501935090840191506000905b80821015614b6a57835167ffffffffffffffff168352928401929184019160019190910190614b40565b50506040860151606086015280935050505092915050565b601f821115610b6557600081815260208120601f850160051c81016020861015614ba95750805b601f850160051c820191505b8181101561228657828155600101614bb5565b815167ffffffffffffffff811115614be257614be2613959565b614bf681614bf08454614332565b84614b82565b602080601f831160018114614c495760008415614c135750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555612286565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015614c9657888601518255948401946001909101908401614c77565b5085821015614cd257878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b600081518084526020808501945080840160005b83811015614d2857815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101614cf6565b509495945050505050565b600081518084526020808501945080840160005b83811015614d2857815167ffffffffffffffff1687529582019590820190600101614d47565b606081526000614d80606083018661437f565b8281036020840152614d928186614ce2565b905082810360408401526137ca8185614d33565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff84168152606060208201526000614e14606083018561437f565b82810360408401526137ca818561423e565b600060208284031215614e3857600080fd5b5051919050565b848152836020820152608060408201526000614e5e6080830185614ce2565b8281036060840152614e708185614d33565b979650505050505050565b60008351614e8d81846020880161421a565b9190910191825250602001919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112614f0157600080fd5b83018035915067ffffffffffffffff821115614f1c57600080fd5b60200191503681900382131561395257600080fd5b600060208284031215614f4357600080fd5b6135c482613fa6565b67ffffffffffffffff818116838216019080821115614f6d57614f6d6146fa565b5092915050565b600067ffffffffffffffff808316818103614f9157614f916146fa565b6001019392505050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60006101008e83528d602084015273ffffffffffffffffffffffffffffffffffffffff8d1660408401528060608401526150208184018d61437f565b90508281036080840152615035818b8d614f9b565b905082810360a084015261504a81898b614f9b565b905082810360c084015261505f818789614f9b565b905082810360e0840152615074818587614f9b565b9f9e505050505050505050505050505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516150bf81601785016020880161421a565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516150fc81602884016020880161421a565b01602801949350505050565b808202811582820484141761076b5761076b6146fa565b8082018082111561076b5761076b6146fa565b600081615141576151416146fa565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a164736f6c6343000815000a
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
BSC | 100.00% | $584.79 | 0.004 | $2.34 |
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.