Overview
S Balance
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 Source Code Verified (Exact Match)
Contract Name:
UDFOracle
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
No with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BSL1.1 pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import "../lib/UnsafeCalldataBytesLib.sol"; import "./VerificationLib.sol"; // import "hardhat/console.sol"; contract UDFOracle is Initializable, UUPSUpgradeable, OwnableUpgradeable, AccessControlUpgradeable { error UDFOracle__PullOracleFeeNotReceived(); error UDFOracle__OutdatedData(); error UDFOracle__DataFeedNotInMessage(); bytes32 public constant ADMIN = keccak256("ADMIN"); bytes32 public constant PUBLISHER = keccak256("PUBLISHER"); uint256 public pullCommision; struct LatestUpdate { /// @notice The price for asset from latest update uint256 latestPrice; /// @notice The timestamp of latest update uint256 latestTimestamp; } VerificationLib public verificationLib; /// @notice mapping of dataKey to the latest update mapping(bytes32 dataKey => LatestUpdate) public latestUpdate; /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize( address _verificationLib, uint256 _pullComission ) public initializer { __Ownable_init(); __UUPSUpgradeable_init(); verificationLib = VerificationLib(_verificationLib); pullCommision = _pullComission; _setRoleAdmin(ADMIN, ADMIN); _setRoleAdmin(PUBLISHER, ADMIN); _grantRole(ADMIN, msg.sender); } function _authorizeUpgrade(address) internal override onlyOwner {} /// @notice Accept updates encoded to array of bytes, verifies the updates and returns(pull model) /// @param encodedData The encoded data - `<MAGIC><n_updates>(<feedKey><n_votes>(<feedKey><value><timestamp><sig_r><sig_s><sig_v>)...)...` /// @param dataFeedId Array of data feed ids /** *@dev Data format for EVM chain updates. * * Format: <MAGIC><n_updates>(<feedKey><n_votes>(<feedKey><value><timestamp><sig_r><sig_s><sig_v>)...)... * * Structure: * - `Magic feed data key` (4 bytes): MAGIC (must be 0x55444646 for UDF) * - `update_length` (1 byte): Number of updates. * - `updates_array`: * * - `feedKey` (8 bytes) * - `n_votes` (1 byte) * * - `votes_array`: * * - `value` (8 bytes) * - `timestamp` (8 bytes) * - `r` (8 bytes): R component of the signature. * - `s` (8 bytes): S component of the signature. * - `v` (1 byte): V component of the signature. * * - `end_of_votes_array` * * - `end_of_updates_array` */ function getOraclePriceUpdatesFromMsg( bytes calldata updateMsg, bytes32[] memory dataFeedIds ) external payable returns (LatestUpdate[] memory updates) { updates = new LatestUpdate[](dataFeedIds.length); uint8 nUpdates = UnsafeCalldataBytesLib.toUint8(updateMsg, 4); if (msg.value < pullCommision * nUpdates) { revert UDFOracle__PullOracleFeeNotReceived(); } (uint256[] memory values, uint256[] memory timestamps,) = verificationLib.processDataForFeeds( updateMsg, dataFeedIds ); for (uint8 i; i < values.length;) { updates[i] = LatestUpdate({latestTimestamp: timestamps[i], latestPrice: values[i]}); unchecked { i++; } } } /// @notice Accept updates encoded to array of bytes, verifies the updates and returns(pull model) /// @param updateMsg The encoded data - `<MAGIC><n_updates>(<feedKey><n_votes>(<feedKey><value><timestamp><sig_r><sig_s><sig_v>)...)...` /// @param dataFeedId Data feed id function getOraclePriceUpdateFromMsg(bytes calldata updateMsg, bytes32 dataFeedId) external payable returns (LatestUpdate memory update) { uint8 nUpdates = UnsafeCalldataBytesLib.toUint8(updateMsg, 4); if (msg.value < pullCommision * nUpdates) { revert UDFOracle__PullOracleFeeNotReceived(); } (uint256 value, uint256 timestamp) = verificationLib.processDataForFeed( updateMsg, dataFeedId ); return LatestUpdate({latestPrice: value, latestTimestamp: timestamp}); } /// @notice Accept updates encoded to array of bytes, verifies the updates and stores on chain /// @param encodedData The encoded data - `<MAGIC><n_updates>(<feedKey><n_votes>(<feedKey><value><timestamp><sig_r><sig_s><sig_v>)...)...` /** *@dev Data format for EVM chain updates. * * Format: <MAGIC><n_updates>(<feedKey><n_votes>(<feedKey><value><timestamp><sig_r><sig_s><sig_v>)...)... * * Structure: * - `Magic feed data key` (4 bytes): MAGIC (must be 0x55444646 for UDF) * - `update_length` (1 byte): Number of updates. * - `updates_array`: * * - `feedKey` (8 bytes) * - `n_votes` (1 byte) * * - `votes_array`: * * - `value` (8 bytes) * - `timestamp` (8 bytes) * - `r` (8 bytes): R component of the signature. * - `s` (8 bytes): S component of the signature. * - `v` (1 byte): V component of the signature. * * - `end_of_votes_array` * * - `end_of_updates_array` */ function pushPriceFeeds( bytes calldata encodedUpdates ) external onlyRole(PUBLISHER) { ( uint256[] memory values, uint256[] memory timestamps, bytes32[] memory feedKeys ) = verificationLib.processData(encodedUpdates); for (uint8 i = 0; i < values.length; ) { // Load the latest update into memory LatestUpdate storage latest = latestUpdate[feedKeys[i]]; if (latest.latestTimestamp < timestamps[i]) { // Store the median value with corresponding feedKey and timestamp latest.latestPrice = values[i]; latest.latestTimestamp = timestamps[i]; } unchecked { i++; } } } function getUpdateFee(uint256 nFeeds) external view returns (uint256) { return pullCommision * nFeeds; } function calcPullOracleComission( bytes calldata encodedUpdates ) external view returns (uint256) { uint8 nUpdates = UnsafeCalldataBytesLib.toUint8(encodedUpdates, 4); return pullCommision * nUpdates; } function setVerificationLibAddress( address _verificationLib ) external onlyRole(ADMIN) { verificationLib = VerificationLib(_verificationLib); } function setPullOracleComission( uint256 _comission ) external onlyRole(ADMIN) { pullCommision = _comission; } }
//SPDX-License-Identifier: BSL 1.1 pragma solidity ^0.8.19; interface IEndPoint { /// @notice protocol info struct struct AllowedProtocolInfo { bool isCreated; uint256 consensusTargetRate; // percentage of proofs div numberOfAllowedTransmitters which should be reached to approve operation. Scaled with 10000 decimals, e.g. 6000 is 60% } function numberOfAllowedTransmitters(bytes32 protocolId) external view returns (uint256); function allowedProtocolInfo(bytes32 protocolId) external view returns (bool isCreated, uint256 consensusTargetRate); function allowedTransmitters(bytes32 protocolId, address transmitter) external view returns (bool); }
// 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 {Initializable} from "../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 { 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); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @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.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @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.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 {Initializable} from "../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 { // 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; function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } /** * @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} from "./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 { /// @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"); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @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.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 (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; import {Initializable} from "../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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } /** * @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 {Initializable} from "../../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.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 IERC1822Proxiable { /** * @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 IERC1967 { /** * @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 IBeacon { /** * @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.7.0) (proxy/ERC1967/ERC1967Proxy.sol) pragma solidity ^0.8.0; import "../Proxy.sol"; import "./ERC1967Upgrade.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializing the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { _upgradeToAndCall(_logic, _data, false); } /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { return ERC1967Upgrade._getImplementation(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../interfaces/IERC1967.sol"; import "../../interfaces/draft-IERC1822.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.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 ERC1967Upgrade is IERC1967 { // 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 StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.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) { Address.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 (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822Proxiable(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 StorageSlot.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"); StorageSlot.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 StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.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) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overridden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} }
// 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 Address { /** * @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 (last updated v4.9.2) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { require(proofPos == proofLen, "MerkleProof: invalid multiproof"); unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { require(proofPos == proofLen, "MerkleProof: invalid multiproof"); unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// 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 StorageSlot { 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: BSL1.1 pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@entangle_protocol/oracle-sdk/contracts/interfaces/IEndPoint.sol"; import "../lib/UnsafeCalldataBytesLib.sol"; // import "hardhat/console.sol"; contract VerificationLib is Initializable, AccessControlUpgradeable, UUPSUpgradeable, OwnableUpgradeable { error VerificationLib__WrongUDFMagic(); error VerificationLib__ZeroVotes(); error VerificationLib__NotAllowedTransmitter(address); error VerificationLib__VotesTimestampExpired(); error VerificationLib__DuplicateTransmitter(address); error VerificationLib__VotesThresholdNotReached(uint256); error VerificationLib__NotSortedVotes(); error VerificationLib__UpdateNotFound(bytes32 feedKey); error VerificationLib__ZeroSignerAddress(); error VerificationLib__FeedNotFound(); bytes32 public constant ADMIN = keccak256("ADMIN"); bytes32 public protocolId; uint256 public timeThreshold; // threshold time in seconds uint256 public votesThreshold; IEndPoint public endPoint; /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } /// @notice Initializer /// @param initAddr - 0: admin function initialize( address[1] calldata initAddr, bytes32 _protocolId, uint256 _timeThreshold, uint256 _votesThreshold, address _endPoint ) public initializer { __Ownable_init(); __UUPSUpgradeable_init(); protocolId = _protocolId; endPoint = IEndPoint(_endPoint); timeThreshold = _timeThreshold; votesThreshold = _votesThreshold; _setRoleAdmin(ADMIN, ADMIN); _grantRole(ADMIN, initAddr[0]); } function _authorizeUpgrade(address) internal override onlyOwner {} function processData( bytes calldata encodedUpdates ) external view returns (uint256[] memory, uint256[] memory, bytes32[] memory) { // Decode the MAGIC number (first 4 bytes) bytes4 magic = UnsafeCalldataBytesLib.toBytes4(encodedUpdates, 0); if (magic != 0x55444646) { revert VerificationLib__WrongUDFMagic(); } // console.logBytes4(magic); // Number of updates (next byte) uint8 nUpdates = UnsafeCalldataBytesLib.toUint8(encodedUpdates, 4); // console.log(nUpdates); uint256 offset = 5; // Start after MAGIC and nUpdates uint256[] memory medianUpdates = new uint256[](nUpdates); uint256[] memory timestampUpdates = new uint256[](nUpdates); bytes32[] memory feedKeyUpdates = new bytes32[](nUpdates); uint256 _timeThreshold = timeThreshold; uint256 _votesThreshold = votesThreshold; IEndPoint _endPoint = endPoint; bytes32 _protocolId = protocolId; for (uint8 i = 0; i < nUpdates; i++) { bytes32 feedKey = UnsafeCalldataBytesLib.toBytes32( encodedUpdates, offset ); offset += 32; // Move past feedKey // console.logBytes32(feedKey); uint8 nVotes = UnsafeCalldataBytesLib.toUint8( encodedUpdates, offset ); // console.log(nVotes); if (nVotes == 0) { revert VerificationLib__ZeroVotes(); } offset += 1; // Move past nVotes uint256[] memory values = new uint256[](nVotes); uint256[] memory timestamps = new uint256[](nVotes); address[] memory uniqueSigners = new address[](nVotes); uint256 nUniqueSigners = 0; for (uint8 j = 0; j < nVotes; j++) { uint256 value = UnsafeCalldataBytesLib.toUint256( encodedUpdates, offset ); offset += 32; // Move past value // console.log(value); uint256 timestamp = UnsafeCalldataBytesLib.toUint256( encodedUpdates, offset ); offset += 32; // Move past timestamp // console.log(timestamp); bytes32 r = UnsafeCalldataBytesLib.toBytes32( encodedUpdates, offset ); offset += 32; // Move past r // console.logBytes32(r); bytes32 s = UnsafeCalldataBytesLib.toBytes32( encodedUpdates, offset ); offset += 32; // Move past s // console.logBytes32(s); uint8 v = UnsafeCalldataBytesLib.toUint8( encodedUpdates, offset ); offset += 1; // Move past v // Verify signature bytes32 messageHash = keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked(feedKey, value, timestamp)) ) ); address signer = ecrecover(messageHash, v, r, s); if (signer == address(0)) { revert VerificationLib__ZeroSignerAddress(); } bool isAllowed = _endPoint.allowedTransmitters( _protocolId, signer ); if (!isAllowed) { revert VerificationLib__NotAllowedTransmitter(signer); } // Check for duplicate signer bool isDuplicate = false; for (uint256 k = 0; k < nUniqueSigners; k++) { if (uniqueSigners[k] == signer) { isDuplicate = true; break; } } if (isDuplicate) { revert VerificationLib__DuplicateTransmitter(signer); } // Store this signer as unique uniqueSigners[nUniqueSigners] = signer; nUniqueSigners++; // Store values and timestamps values[j] = value; timestamps[j] = timestamp; } if (nUniqueSigners < _votesThreshold) { revert VerificationLib__VotesThresholdNotReached( nUniqueSigners ); } // console.log(timestamps[0]); // Check if more than half of votes are older than the threshold if (!isRecent(_timeThreshold, timestamps)) { revert VerificationLib__VotesTimestampExpired(); } // Calculate the median value from values array medianUpdates[i] = calculateMedian(values); timestampUpdates[i] = _max(timestamps); feedKeyUpdates[i] = feedKey; } return (medianUpdates, timestampUpdates, feedKeyUpdates); } function processDataForFeeds( bytes calldata encodedUpdates, bytes32[] memory targetFeedIds ) external view returns ( uint256[] memory filteredValues, uint256[] memory filteredTimestamps, bytes32[] memory filteredFeedKeys ) { bytes4 magic = UnsafeCalldataBytesLib.toBytes4(encodedUpdates, 0); if (magic != 0x55444646) { revert VerificationLib__WrongUDFMagic(); } uint8 nUpdates = UnsafeCalldataBytesLib.toUint8(encodedUpdates, 4); filteredValues = new uint256[](targetFeedIds.length); filteredTimestamps = new uint256[](targetFeedIds.length); filteredFeedKeys = new bytes32[](targetFeedIds.length); bool[] memory foundFeeds = new bool[](targetFeedIds.length); uint256 foundCount = 0; uint256 offset = 5; uint256 _timeThreshold = timeThreshold; uint256 _votesThreshold = votesThreshold; IEndPoint _endPoint = endPoint; bytes32 _protocolId = protocolId; for (uint8 i = 0; i < nUpdates; ) { bytes32 feedKey = UnsafeCalldataBytesLib.toBytes32(encodedUpdates, offset); offset += 32; uint8 nVotes = UnsafeCalldataBytesLib.toUint8(encodedUpdates, offset); if (nVotes == 0) { revert VerificationLib__ZeroVotes(); } offset += 1; uint256 targetIndex = type(uint256).max; bool isNeeded = false; for (uint256 j = 0; j < targetFeedIds.length; ) { if (!foundFeeds[j] && feedKey == targetFeedIds[j]) { isNeeded = true; targetIndex = j; foundFeeds[j] = true; unchecked { foundCount++; } break; } unchecked { ++j; } } if (isNeeded && targetIndex != type(uint256).max) { uint256[] memory values = new uint256[](nVotes); uint256[] memory timestamps = new uint256[](nVotes); address[] memory uniqueSigners = new address[](nVotes); uint256 nUniqueSigners = 0; for (uint8 j = 0; j < nVotes; ) { uint256 value = UnsafeCalldataBytesLib.toUint256(encodedUpdates, offset); offset += 32; uint256 timestamp = UnsafeCalldataBytesLib.toUint256(encodedUpdates, offset); offset += 32; bytes32 r = UnsafeCalldataBytesLib.toBytes32(encodedUpdates, offset); offset += 32; bytes32 s = UnsafeCalldataBytesLib.toBytes32(encodedUpdates, offset); offset += 32; uint8 v = UnsafeCalldataBytesLib.toUint8(encodedUpdates, offset); offset += 1; bytes32 messageHash = keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked(feedKey, value, timestamp)) ) ); address signer = ecrecover(messageHash, v, r, s); if (signer == address(0)) { revert VerificationLib__ZeroSignerAddress(); } bool isAllowed = _endPoint.allowedTransmitters(_protocolId, signer); if (!isAllowed) { revert VerificationLib__NotAllowedTransmitter(signer); } bool isDuplicate = false; for (uint256 k = 0; k < nUniqueSigners; ) { if (uniqueSigners[k] == signer) { isDuplicate = true; break; } unchecked { ++k; } } if (isDuplicate) { revert VerificationLib__DuplicateTransmitter(signer); } uniqueSigners[nUniqueSigners] = signer; unchecked { ++nUniqueSigners; } values[j] = value; timestamps[j] = timestamp; unchecked { ++j; } } if (nUniqueSigners < _votesThreshold) { revert VerificationLib__VotesThresholdNotReached(nUniqueSigners); } if (!isRecent(_timeThreshold, timestamps)) { revert VerificationLib__VotesTimestampExpired(); } filteredValues[targetIndex] = calculateMedian(values); filteredTimestamps[targetIndex] = _max(timestamps); filteredFeedKeys[targetIndex] = feedKey; } else { offset += uint256(nVotes) * (32 + 32 + 32 + 32 + 1); } unchecked { ++i; } } for (uint256 i = 0; i < targetFeedIds.length;) { if (!foundFeeds[i]) { revert VerificationLib__FeedNotFound(); } unchecked { ++i; } } return (filteredValues, filteredTimestamps, filteredFeedKeys); } function processDataForFeed( bytes calldata encodedUpdates, bytes32 targetFeedId ) external view returns ( uint256 value, uint256 timestamp ) { bytes4 magic = UnsafeCalldataBytesLib.toBytes4(encodedUpdates, 0); if (magic != 0x55444646) { revert VerificationLib__WrongUDFMagic(); } uint8 nUpdates = UnsafeCalldataBytesLib.toUint8(encodedUpdates, 4); uint256 offset = 5; uint256 _votesThreshold = votesThreshold; IEndPoint _endPoint = endPoint; bytes32 _protocolId = protocolId; for (uint8 i = 0; i < nUpdates; ) { bytes32 feedKey = UnsafeCalldataBytesLib.toBytes32(encodedUpdates, offset); offset += 32; uint8 nVotes = UnsafeCalldataBytesLib.toUint8(encodedUpdates, offset); if (nVotes == 0) { revert VerificationLib__ZeroVotes(); } offset += 1; if (feedKey == targetFeedId) { uint256[] memory values = new uint256[](nVotes); uint256[] memory timestamps = new uint256[](nVotes); address[] memory uniqueSigners = new address[](nVotes); uint256 nUniqueSigners = 0; for (uint8 j = 0; j < nVotes; ) { uint256 currentValue = UnsafeCalldataBytesLib.toUint256(encodedUpdates, offset); offset += 32; uint256 currentTimestamp = UnsafeCalldataBytesLib.toUint256(encodedUpdates, offset); offset += 32; bytes32 r = UnsafeCalldataBytesLib.toBytes32(encodedUpdates, offset); offset += 32; bytes32 s = UnsafeCalldataBytesLib.toBytes32(encodedUpdates, offset); offset += 32; uint8 v = UnsafeCalldataBytesLib.toUint8(encodedUpdates, offset); offset += 1; bytes32 messageHash = keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked(feedKey, currentValue, currentTimestamp)) ) ); address signer = ecrecover(messageHash, v, r, s); if (signer == address(0)) { revert VerificationLib__ZeroSignerAddress(); } bool isAllowed = _endPoint.allowedTransmitters(_protocolId, signer); if (!isAllowed) { revert VerificationLib__NotAllowedTransmitter(signer); } bool isDuplicate = false; for (uint256 k = 0; k < nUniqueSigners; ) { if (uniqueSigners[k] == signer) { isDuplicate = true; break; } unchecked { ++k; } } if (isDuplicate) { revert VerificationLib__DuplicateTransmitter(signer); } uniqueSigners[nUniqueSigners] = signer; unchecked { ++nUniqueSigners; } values[j] = currentValue; timestamps[j] = currentTimestamp; unchecked { ++j; } } if (nUniqueSigners < _votesThreshold) { revert VerificationLib__VotesThresholdNotReached(nUniqueSigners); } return ( calculateMedian(values), _max(timestamps) ); } else { offset += nVotes * (32 + 32 + 32 + 32 + 1); // value + timestamp + r + s + v } unchecked { ++i; } } revert VerificationLib__UpdateNotFound(targetFeedId); } // TODO turn this functions to internal after testing function calculateMedian( uint256[] memory values ) internal pure returns (uint256) { uint256 length = values.length; // Check if the array is sorted for (uint256 i = 0; i < length - 1; i++) { if (values[i] > values[i + 1]) { revert VerificationLib__NotSortedVotes(); } } // Calculate median if (length % 2 == 1) { return values[length / 2]; // Odd case } else { return (values[length / 2 - 1] + values[length / 2]) / 2; // Even case } } function isRecent( uint256 _timeThreshold, uint256[] memory timestamps ) internal view returns (bool) { uint256 countOlder = 0; uint256 currentTime = block.timestamp; // console.log(currentTime); for (uint256 i = 0; i < timestamps.length; i++) { if (currentTime - timestamps[i] > _timeThreshold) { countOlder++; } } return countOlder <= timestamps.length / 2; // More than half should not be older } function _max(uint256[] memory numbers) internal pure returns (uint256) { uint256 maxNumber; for (uint256 i = 0; i < numbers.length; i++) { if (numbers[i] > maxNumber) { maxNumber = numbers[i]; } } return maxNumber; } function setEndpointAddress(address _endPoint) external onlyRole(ADMIN) { endPoint = IEndPoint(_endPoint); } function setVotesThreshold(uint256 _votesNum) external onlyRole(ADMIN) { votesThreshold = _votesNum; } function setTimeThreshold(uint256 _timeThreshold) external onlyRole(ADMIN) { timeThreshold = _timeThreshold; } }
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. * * @notice This is the **unsafe** version of BytesLib which removed all the checks (out of bound, ...) * to be more gas efficient. */ pragma solidity >=0.8.0 <0.9.0; library UnsafeCalldataBytesLib { function slice( bytes calldata _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes calldata) { return _bytes[_start:_start + _length]; } function sliceFrom( bytes calldata _bytes, uint256 _start ) internal pure returns (bytes calldata) { return _bytes[_start:_bytes.length]; } function toAddress( bytes calldata _bytes, uint256 _start ) internal pure returns (address) { address tempAddress; assembly { tempAddress := shr(96, calldataload(add(_bytes.offset, _start))) } return tempAddress; } function toUint8( bytes calldata _bytes, uint256 _start ) internal pure returns (uint8) { uint8 tempUint; assembly { tempUint := shr(248, calldataload(add(_bytes.offset, _start))) } return tempUint; } function toUint16( bytes calldata _bytes, uint256 _start ) internal pure returns (uint16) { uint16 tempUint; assembly { tempUint := shr(240, calldataload(add(_bytes.offset, _start))) } return tempUint; } function toUint32( bytes calldata _bytes, uint256 _start ) internal pure returns (uint32) { uint32 tempUint; assembly { tempUint := shr(224, calldataload(add(_bytes.offset, _start))) } return tempUint; } function toUint64( bytes calldata _bytes, uint256 _start ) internal pure returns (uint64) { uint64 tempUint; assembly { tempUint := shr(192, calldataload(add(_bytes.offset, _start))) } return tempUint; } function toUint96( bytes calldata _bytes, uint256 _start ) internal pure returns (uint96) { uint96 tempUint; assembly { tempUint := shr(160, calldataload(add(_bytes.offset, _start))) } return tempUint; } function toUint128( bytes calldata _bytes, uint256 _start ) internal pure returns (uint128) { uint128 tempUint; assembly { tempUint := shr(128, calldataload(add(_bytes.offset, _start))) } return tempUint; } function toUint256( bytes calldata _bytes, uint256 _start ) internal pure returns (uint256) { uint256 tempUint; assembly { tempUint := calldataload(add(_bytes.offset, _start)) } return tempUint; } function toBytes32( bytes calldata _bytes, uint256 _start ) internal pure returns (bytes32) { bytes32 tempBytes32; assembly { tempBytes32 := calldataload(add(_bytes.offset, _start)) } return tempBytes32; } function toBytes4( bytes calldata _bytes, uint256 _start ) internal pure returns (bytes4) { bytes4 tempBytes4; assembly { tempBytes4 := calldataload(add(_bytes.offset, _start)) } return tempBytes4; } }
{ "evmVersion": "paris", "viaIR": true, "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"UDFOracle__DataFeedNotInMessage","type":"error"},{"inputs":[],"name":"UDFOracle__OutdatedData","type":"error"},{"inputs":[],"name":"UDFOracle__PullOracleFeeNotReceived","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":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","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":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PUBLISHER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedUpdates","type":"bytes"}],"name":"calcPullOracleComission","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"updateMsg","type":"bytes"},{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"getOraclePriceUpdateFromMsg","outputs":[{"components":[{"internalType":"uint256","name":"latestPrice","type":"uint256"},{"internalType":"uint256","name":"latestTimestamp","type":"uint256"}],"internalType":"struct UDFOracle.LatestUpdate","name":"update","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"updateMsg","type":"bytes"},{"internalType":"bytes32[]","name":"dataFeedIds","type":"bytes32[]"}],"name":"getOraclePriceUpdatesFromMsg","outputs":[{"components":[{"internalType":"uint256","name":"latestPrice","type":"uint256"},{"internalType":"uint256","name":"latestTimestamp","type":"uint256"}],"internalType":"struct UDFOracle.LatestUpdate[]","name":"updates","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nFeeds","type":"uint256"}],"name":"getUpdateFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_verificationLib","type":"address"},{"internalType":"uint256","name":"_pullComission","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataKey","type":"bytes32"}],"name":"latestUpdate","outputs":[{"internalType":"uint256","name":"latestPrice","type":"uint256"},{"internalType":"uint256","name":"latestTimestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pullCommision","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedUpdates","type":"bytes"}],"name":"pushPriceFeeds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","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":"_comission","type":"uint256"}],"name":"setPullOracleComission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_verificationLib","type":"address"}],"name":"setVerificationLibAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","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":"verificationLib","outputs":[{"internalType":"contract VerificationLib","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a06040523461004c5761001161005c565b610019610051565b6138f161031d8239608051818181611286015281816112ca0152818161144b0152818161148f015261163701526138f190f35b610057565b60405190565b600080fd5b61006461006e565b61006c610290565b565b610076610078565b565b610080610082565b565b61008a61008c565b565b610094610096565b565b61009e6100a0565b565b6100a86100ec565b565b60018060a01b031690565b90565b6100cc6100c76100d1926100aa565b6100b5565b6100aa565b90565b6100dd906100b8565b90565b6100e9906100d4565b90565b6100f5306100e0565b608052565b60081c90565b60ff1690565b610112610117916100fa565b610100565b90565b6101249054610106565b90565b151590565b60209181520190565b60207f616c697a696e6700000000000000000000000000000000000000000000000000917f496e697469616c697a61626c653a20636f6e747261637420697320696e69746960008201520152565b610190602760409261012c565b61019981610135565b0190565b6101b39060208101906000818303910152610183565b90565b156101bd57565b6101c5610051565b62461bcd60e51b8152806101db6004820161019d565b0390fd5b60001c90565b60ff1690565b6101f76101fc916101df565b6101e5565b90565b61020990546101eb565b90565b60ff1690565b60001b90565b9061022460ff91610212565b9181191691161790565b61024261023d6102479261020c565b6100b5565b61020c565b90565b90565b9061026261025d6102699261022e565b61024a565b8254610218565b9055565b6102769061020c565b9052565b919061028e9060006020850194019061026d565b565b6102ab6102a66102a0600061011a565b15610127565b6101b6565b6102b560006101ff565b6102c86102c260ff61020c565b9161020c565b036102d0575b565b6102dc60ff600061024d565b60ff6103147f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989161030b610051565b9182918261027a565b0390a16102ce56fe60806040526004361015610013575b610f4a565b61001e6000356101bd565b806301ffc9a7146101b85780630a88a71b146101b3578063248a9ca3146101ae5780632a0acc6a146101a95780632f2ff15d146101a457806336568abe1461019f5780633659cfe61461019a57806349588dd8146101955780634f1ef28614610190578063505649451461018b57806352d1902d14610186578063607563b414610181578063715018a61461017c5780638da5cb5b1461017757806391d1485414610172578063a217fddf1461016d578063a86d0d7614610168578063b228abee14610163578063c7097a9c1461015e578063cd6dc68714610159578063d547741f14610154578063dbfbe5da1461014f578063e17efd481461014a578063ea5a3ec914610145578063f0f0fce9146101405763f2fde38b0361000e57610f17565b610ee1565b610e15565b610da6565b610d71565b610d0e565b610cda565b610c76565b610c27565b610b79565b610987565b610914565b6108df565b610889565b610855565b6107a0565b61076d565b6106fd565b610594565b610561565b61050e565b6104da565b610441565b6103dd565b61033f565b61024f565b60e01c90565b60405190565b600080fd5b600080fd5b600080fd5b63ffffffff60e01b1690565b6101ed816101d8565b036101f457565b600080fd5b90503590610206826101e4565b565b906020828203126102225761021f916000016101f9565b90565b6101ce565b151590565b61023590610227565b9052565b919061024d9060006020850194019061022c565b565b3461027f5761027b61026a610265366004610208565b610f54565b6102726101c3565b91829182610239565b0390f35b6101c9565b600091031261028f57565b6101ce565b1c90565b60018060a01b031690565b6102b39060086102b89302610294565b610298565b90565b906102c691546102a3565b90565b6102d761012e6000906102bb565b90565b60018060a01b031690565b90565b6102fc6102f7610301926102da565b6102e5565b6102da565b90565b61030d906102e8565b90565b61031990610304565b90565b61032590610310565b9052565b919061033d9060006020850194019061031c565b565b3461036f5761034f366004610284565b61036b61035a6102c9565b6103626101c3565b91829182610329565b0390f35b6101c9565b90565b61038081610374565b0361038757565b600080fd5b9050359061039982610377565b565b906020828203126103b5576103b29160000161038c565b90565b6101ce565b6103c390610374565b9052565b91906103db906000602085019401906103ba565b565b3461040d576104096103f86103f336600461039b565b610fd5565b6104006101c3565b918291826103c7565b0390f35b6101c9565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4290565b61043e610412565b90565b3461047157610451366004610284565b61046d61045c610436565b6104646101c3565b918291826103c7565b0390f35b6101c9565b61047f906102da565b90565b61048b81610476565b0361049257565b600080fd5b905035906104a482610482565b565b91906040838203126104cf57806104c36104cc926000860161038c565b93602001610497565b90565b6101ce565b60000190565b34610509576104f36104ed3660046104a6565b90611020565b6104fb6101c3565b80610505816104d4565b0390f35b6101c9565b3461053d576105276105213660046104a6565b906110df565b61052f6101c3565b80610539816104d4565b0390f35b6101c9565b9060208282031261055c5761055991600001610497565b90565b6101ce565b3461058f57610579610574366004610542565b611389565b6105816101c3565b8061058b816104d4565b0390f35b6101c9565b346105c2576105ac6105a7366004610542565b611427565b6105b46101c3565b806105be816104d4565b0390f35b6101c9565b600080fd5b600080fd5b601f801991011690565b634e487b7160e01b600052604160045260246000fd5b906105fb906105d1565b810190811067ffffffffffffffff82111761061557604052565b6105db565b9061062d6106266101c3565b92836105f1565b565b67ffffffffffffffff811161064d576106496020916105d1565b0190565b6105db565b90826000939282370152565b9092919261067361066e8261062f565b61061a565b9381855260208501908284011161068f5761068d92610652565b565b6105cc565b9080601f830112156106b2578160206106af9335910161065e565b90565b6105c7565b9190916040818403126106f8576106d18360008301610497565b92602082013567ffffffffffffffff81116106f3576106f09201610694565b90565b6101d3565b6101ce565b61071161070b3660046106b7565b906114df565b6107196101c3565b80610723816104d4565b0390f35b90565b61073381610727565b0361073a57565b600080fd5b9050359061074c8261072a565b565b90602082820312610768576107659160000161073f565b90565b6101ce565b3461079b5761078561078036600461074e565b61156a565b61078d6101c3565b80610797816104d4565b0390f35b6101c9565b346107d0576107b0366004610284565b6107cc6107bb6116c6565b6107c36101c3565b918291826103c7565b0390f35b6101c9565b600080fd5b600080fd5b909182601f830112156108195781359167ffffffffffffffff831161081457602001926001830284011161080f57565b6107da565b6107d5565b6105c7565b9060208282031261085057600082013567ffffffffffffffff811161084b5761084792016107df565b9091565b6101d3565b6101ce565b346108845761086e61086836600461081e565b90611b80565b6108766101c3565b80610880816104d4565b0390f35b6101c9565b346108b757610899366004610284565b6108a1611bda565b6108a96101c3565b806108b3816104d4565b0390f35b6101c9565b6108c590610476565b9052565b91906108dd906000602085019401906108bc565b565b3461090f576108ef366004610284565b61090b6108fa611c15565b6109026101c3565b918291826108c9565b0390f35b6101c9565b346109455761094161093061092a3660046104a6565b90611c76565b6109386101c3565b91829182610239565b0390f35b6101c9565b90565b60001b90565b61096761096261096c9261094a565b61094d565b610374565b90565b6109796000610953565b90565b61098461096f565b90565b346109b757610997366004610284565b6109b36109a261097c565b6109aa6101c3565b918291826103c7565b0390f35b6101c9565b67ffffffffffffffff81116109d45760208091020190565b6105db565b909291926109ee6109e9826109bc565b61061a565b9381855260208086019202830192818411610a2b57915b838310610a125750505050565b60208091610a20848661038c565b815201920191610a05565b6107da565b9080601f83011215610a4e57816020610a4b933591016109d9565b90565b6105c7565b9091604082840312610aad57600082013567ffffffffffffffff8111610aa85783610a7f9184016107df565b929093602082013567ffffffffffffffff8111610aa357610aa09201610a30565b90565b6101d3565b6101d3565b6101ce565b5190565b60209181520190565b60200190565b610ace90610727565b9052565b90602080610af693610aec60008201516000860190610ac5565b0151910190610ac5565b565b90610b0581604093610ad2565b0190565b60200190565b90610b2c610b26610b1f84610ab2565b8093610ab6565b92610abf565b9060005b818110610b3d5750505090565b909192610b56610b506001928651610af8565b94610b09565b9101919091610b30565b610b769160208201916000818403910152610b0f565b90565b610ba1610b90610b8a366004610a53565b91611ec3565b610b986101c3565b91829182610b60565b0390f35b91604083830312610be657600083013567ffffffffffffffff8111610be157610bd383610bde9286016107df565b93909460200161038c565b90565b6101d3565b6101ce565b90602080610c0f93610c0560008201516000860190610ac5565b0151910190610ac5565b565b9190610c2590600060408501940190610beb565b565b610c4f610c3e610c38366004610ba5565b916120f1565b610c466101c3565b91829182610c11565b0390f35b610c5c90610727565b9052565b9190610c7490600060208501940190610c53565b565b34610ca757610ca3610c92610c8c36600461081e565b9061221f565b610c9a6101c3565b91829182610c60565b0390f35b6101c9565b9190604083820312610cd55780610cc9610cd29260008601610497565b9360200161073f565b90565b6101ce565b34610d0957610cf3610ced366004610cac565b906125e0565b610cfb6101c3565b80610d05816104d4565b0390f35b6101c9565b34610d3d57610d27610d213660046104a6565b90612615565b610d2f6101c3565b80610d39816104d4565b0390f35b6101c9565b7fad312f08b8889cfe65ec2f1faae419f8b47f0153a3483ea6130918c055c8183d90565b610d6e610d42565b90565b34610da157610d81366004610284565b610d9d610d8c610d66565b610d946101c3565b918291826103c7565b0390f35b6101c9565b34610dd657610dd2610dc1610dbc36600461074e565b612621565b610dc96101c3565b91829182610c60565b0390f35b6101c9565b90565b610dee906008610df39302610294565b610ddb565b90565b90610e019154610dde565b90565b610e1261012d600090610df6565b90565b34610e4557610e25366004610284565b610e41610e30610e04565b610e386101c3565b91829182610c60565b0390f35b6101c9565b610e5390610374565b90565b90610e6090610e4a565b600052602052604060002090565b60001c90565b610e80610e8591610e6e565b610ddb565b90565b610e929054610e74565b90565b610ea19061012f610e56565b90610eba6001610eb360008501610e88565b9301610e88565b90565b916020610edf929493610ed860408201966000830190610c53565b0190610c53565b565b34610f1257610ef9610ef436600461039b565b610e95565b90610f0e610f056101c3565b92839283610ebd565b0390f35b6101c9565b34610f4557610f2f610f2a366004610542565b61272f565b610f376101c3565b80610f41816104d4565b0390f35b6101c9565b600080fd5b600090565b610f5c610f4f565b5080610f77610f71637965db0b60e01b6101d8565b916101d8565b14908115610f84575b5090565b610f8e915061273a565b38610f80565b600090565b90610fa390610e4a565b600052602052604060002090565b90565b610fc0610fc591610e6e565b610fb1565b90565b610fd29054610fb4565b90565b6001610fee610ff492610fe6610f94565b5060fb610f99565b01610fc8565b90565b906110129161100d61100882610fd5565b612760565b611014565b565b9061101e91612794565b565b9061102a91610ff7565b565b60209181520190565b60207f20726f6c657320666f722073656c660000000000000000000000000000000000917f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201520152565b611090602f60409261102c565b61109981611035565b0190565b6110b39060208101906000818303910152611083565b90565b156110bd57565b6110c56101c3565b62461bcd60e51b8152806110db6004820161109d565b0390fd5b9061110c91611107826111016110fb6110f6612837565b610476565b91610476565b146110b6565b612844565b565b61111790610304565b90565b60207f64656c656761746563616c6c0000000000000000000000000000000000000000917f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201520152565b611175602c60409261102c565b61117e8161111a565b0190565b6111989060208101906000818303910152611168565b90565b156111a257565b6111aa6101c3565b62461bcd60e51b8152806111c060048201611182565b0390fd5b60207f6163746976652070726f78790000000000000000000000000000000000000000917f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201520152565b61121f602c60409261102c565b611228816111c4565b0190565b6112429060208101906000818303910152611212565b90565b1561124c57565b6112546101c3565b62461bcd60e51b81528061126a6004820161122c565b0390fd5b6112ff906112b761127e3061110e565b6112b06112aa7f0000000000000000000000000000000000000000000000000000000000000000610476565b91610476565b141561119b565b6112fa6112c26128de565b6112f46112ee7f0000000000000000000000000000000000000000000000000000000000000000610476565b91610476565b14611245565b611360565b565b61131561131061131a9261094a565b6102e5565b610727565b90565b9061132f61132a8361062f565b61061a565b918252565b369037565b9061135e6113468361131d565b92602080611354869361062f565b9201910390611334565b565b6113879061136d81612910565b61137f61137a6000611301565b611339565b600091612ad4565b565b6113929061126e565b565b6113ad906113a86113a3610412565b612760565b611411565b565b6113b8906102e8565b90565b6113c4906113af565b90565b906113d860018060a01b039161094d565b9181191691161790565b6113eb906113af565b90565b90565b9061140661140161140d926113e2565b6113ee565b82546113c7565b9055565b61141d611425916113bb565b61012e6113f1565b565b61143090611394565b565b906114c49161147c6114433061110e565b61147561146f7f0000000000000000000000000000000000000000000000000000000000000000610476565b91610476565b141561119b565b6114bf6114876128de565b6114b96114b37f0000000000000000000000000000000000000000000000000000000000000000610476565b91610476565b14611245565b6114c6565b565b906114dd916114d481612910565b90600191612ad4565b565b906114e991611432565b565b611504906114ff6114fa610412565b612760565b61155c565b565b906115136000199161094d565b9181191691161790565b61153161152c61153692610727565b6102e5565b610727565b90565b90565b9061155161154c6115589261151d565b611539565b8254611506565b9055565b6115689061012d61153c565b565b611573906114eb565b565b60207f6c6564207468726f7567682064656c656761746563616c6c0000000000000000917f555550535570677261646561626c653a206d757374206e6f742062652063616c60008201520152565b6115d0603860409261102c565b6115d981611575565b0190565b6115f390602081019060008183039101526115c3565b90565b156115fd57565b6116056101c3565b62461bcd60e51b81528061161b600482016115dd565b0390fd5b61166c9061166761162f3061110e565b61166161165b7f0000000000000000000000000000000000000000000000000000000000000000610476565b91610476565b146115f6565b6116ba565b90565b90565b61168661168161168b9261166f565b61094d565b610374565b90565b6116b77f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc611672565b90565b506116c361168e565b90565b6116d66116d1610f94565b61161f565b90565b906116f3916116ee6116e9610d42565b612760565b6119ed565b565b61170161170691610e6e565b610298565b90565b61171390546116f5565b90565b60e01b90565b67ffffffffffffffff81116117345760208091020190565b6105db565b905051906117468261072a565b565b9092919261175d6117588261171c565b61061a565b938185526020808601920283019281841161179a57915b8383106117815750505050565b6020809161178f8486611739565b815201920191611774565b6107da565b9080601f830112156117bd578160206117ba93519101611748565b90565b6105c7565b905051906117cf82610377565b565b909291926117e66117e1826109bc565b61061a565b938185526020808601920283019281841161182357915b83831061180a5750505050565b6020809161181884866117c2565b8152019201916117fd565b6107da565b9080601f8301121561184657816020611843935191016117d1565b90565b6105c7565b916060838303126118c857600083015167ffffffffffffffff81116118c3578261187691850161179f565b92602081015167ffffffffffffffff81116118be578361189791830161179f565b92604082015167ffffffffffffffff81116118b9576118b69201611828565b90565b6101d3565b6101d3565b6101d3565b6101ce565b60209181520190565b91906118f0816118e9816118f5956118cd565b8095610652565b6105d1565b0190565b909161191192602083019260008185039101526118d6565b90565b61191c6101c3565b3d6000823e3d90fd5b60ff1690565b61193f61193a6119449261094a565b6102e5565b611925565b90565b5190565b61195f61195a61196492611925565b6102e5565b610727565b90565b634e487b7160e01b600052603260045260246000fd5b5190565b9061198b8261197d565b81101561199c576020809102010190565b611967565b6119ab9051610374565b90565b90565b906119bb82611947565b8110156119cc576020809102010190565b611967565b6119db9051610727565b90565b60016119ea9101611925565b90565b9190600090611a05611a0061012e611709565b610310565b611a27638331ed0f959295611a32611a1b6101c3565b97889586948594611716565b8452600484016118f9565b03915afa918215611b7b5760008080929094611b51575b50929092611a57600061192b565b5b80611a73611a6d611a6885611947565b610727565b9161194b565b1015611b4a57611af090611aac611aa761012f611aa1611a9c8a611a968761194b565b90611981565b6119a1565b90610e56565b6119ae565b611ab860018201610e88565b611ae4611ade611ad9611ad489611ace8861194b565b906119b1565b6119d1565b610727565b91610727565b10611af5575b506119de565b611a58565b611b4490611b20611b17611b1287611b0c8761194b565b906119b1565b6119d1565b6000830161153c565b6001611b3d611b3888611b328761194b565b906119b1565b6119d1565b910161153c565b38611aea565b5050509050565b915050611b729192503d806000833e611b6a81836105f1565b81019061184b565b90929138611a49565b611914565b90611b8a916116d9565b565b611b94612c72565b611b9c611bc6565b565b611bb2611bad611bb79261094a565b6102e5565b6102da565b90565b611bc390611b9e565b90565b611bd8611bd36000611bba565b612cc1565b565b611be2611b8c565b565b600090565b60018060a01b031690565b611c00611c0591610e6e565b611be9565b90565b611c129054611bf4565b90565b611c1d611be4565b50611c286097611c08565b90565b611c3490610304565b90565b90611c4190611c2b565b600052602052604060002090565b60ff1690565b611c61611c6691610e6e565b611c4f565b90565b611c739054611c55565b90565b611c9e916000611c93611c9993611c8b610f4f565b5060fb610f99565b01611c37565b611c69565b90565b606090565b67ffffffffffffffff8111611cbe5760208091020190565b6105db565b90611cd5611cd083611ca6565b61061a565b918252565b611ce4604061061a565b90565b600090565b611cf4611cda565b9060208083611d01611ce7565b815201611d0c611ce7565b81525050565b611d1a611cec565b90565b60005b828110611d2c57505050565b602090611d37611d12565b8184015201611d20565b90611d66611d4e83611cc3565b92602080611d5c8693611ca6565b9201910390611d1d565b565b90565b611d7f611d7a611d8492611d68565b6102e5565b610727565b90565b634e487b7160e01b600052601160045260246000fd5b611dac611db291939293610727565b92610727565b91611dbe838202610727565b928184041490151715611dcd57565b611d87565b60209181520190565b60200190565b611dea90610374565b9052565b90611dfb81602093611de1565b0190565b60200190565b90611e22611e1c611e158461197d565b8093611dd2565b92611ddb565b9060005b818110611e335750505090565b909192611e4c611e466001928651611dee565b94611dff565b9101919091611e26565b91611e809391611e7291604085019185830360008701526118d6565b916020818403910152611e05565b90565b600090565b611e92604061061a565b90565b90611e9f90610727565b9052565b90611ead82610ab2565b811015611ebe576020809102010190565b611967565b92919092611ecf611ca1565b50611ee1611edc8361197d565b611d41565b93611ef78282611ef16004611d6b565b91612d22565b611f27611f21611f1c3493611f16611f1061012d610e88565b9161194b565b90611d9d565b610727565b91610727565b1061207257600091611f65611f45611f4061012e611709565b610310565b91611f70631adb094a919496611f596101c3565b97889687958695611716565b855260048501611e56565b03915afa801561206d57600080929091612046575b5090611f8f611e83565b5b80611fab611fa5611fa086611947565b610727565b9161194b565b10156120415761203c90612035611fd3611fce85611fc88561194b565b906119b1565b6119d1565b612010611ff1611fec88611fe68761194b565b906119b1565b6119d1565b91612007611ffd611e88565b9360008501611e95565b60208301611e95565b61202f889184906120296120238361194b565b85611ea3565b5261194b565b90611ea3565b51506119de565b611f90565b505050565b905061206591503d806000833e61205d81836105f1565b81019061184b565b919091611f85565b611914565b600063a39c577b60e01b81528061208b600482016104d4565b0390fd5b612097611cec565b90565b91906040838203126120c357806120b76120c09260008601611739565b93602001611739565b90565b6101ce565b9392906120e76020916120ef94604088019188830360008a01526118d6565b9401906103ba565b565b906120fa61208f565b50612110828261210a6004611d6b565b91612d22565b61214061213a612135349361212f61212961012d610e88565b9161194b565b90611d9d565b610727565b91610727565b106121fd5760409161217e61215e61215961012e611709565b610310565b9161218963403664759194966121726101c3565b97889687958695611716565b8552600485016120c8565b03915afa80156121f8576000809290916121c5575b506121c290916121b96121af611e88565b9360008501611e95565b60208301611e95565b90565b6121c292506121eb915060403d81116121f1575b6121e381836105f1565b81019061209a565b9161219e565b503d6121d9565b611914565b600063a39c577b60e01b815280612216600482016104d4565b0390fd5b600090565b61225b916122419161222f61221a565b509061223b6004611d6b565b91612d22565b61225561224f61012d610e88565b9161194b565b90611d9d565b90565b60081c90565b6122706122759161225e565b611c4f565b90565b6122829054612264565b90565b60ff1690565b61229761229c91610e6e565b612285565b90565b6122a9905461228b565b90565b90565b6122c36122be6122c8926122ac565b6102e5565b611925565b90565b6122d490610304565b90565b60207f647920696e697469616c697a6564000000000000000000000000000000000000917f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160008201520152565b612332602e60409261102c565b61233b816122d7565b0190565b6123559060208101906000818303910152612325565b90565b1561235f57565b6123676101c3565b62461bcd60e51b81528061237d6004820161233f565b0390fd5b9061238d60ff9161094d565b9181191691161790565b6123ab6123a66123b092611925565b6102e5565b611925565b90565b90565b906123cb6123c66123d292612397565b6123b3565b8254612381565b9055565b60081b90565b906123e961ff00916123d6565b9181191691161790565b6123fc90610227565b90565b90565b9061241761241261241e926123f3565b6123ff565b82546123dc565b9055565b61242b906122af565b9052565b919061244390600060208501940190612422565b565b906124949061245d6124576000612278565b15610227565b928380612546575b80156124f7575b61247590612358565b61248961248260016122af565b60006123b6565b836124e6575b61256a565b61249b575b565b6124a6600080612402565b60016124de7f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498916124d56101c3565b9182918261242f565b0390a1612499565b6124f260016000612402565b61248f565b5061251261250c612507306122cb565b612d3e565b15610227565b8061251d575b61246c565b5061247561252b600061229f565b61253e61253860016122af565b91611925565b149050612518565b50612551600061229f565b61256461255e60016122af565b91611925565b10612465565b9061259261258a61259a9361257d612e2f565b612585612e4d565b6113bb565b61012e6113f1565b61012d61153c565b6125b36125a5610412565b6125ad610412565b90612e83565b6125cc6125be610d42565b6125c6610412565b90612e83565b6125de6125d7610412565b3390612794565b565b906125ea91612445565b565b90612607916126026125fd82610fd5565b612760565b612609565b565b9061261391612844565b565b9061261f916125ec565b565b61263e9061262d61221a565b5061263961012d610e88565b611d9d565b90565b6126529061264d612c72565b6126fe565b565b60207f6464726573730000000000000000000000000000000000000000000000000000917f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201520152565b6126af602660409261102c565b6126b881612654565b0190565b6126d290602081019060008183039101526126a2565b90565b156126dc57565b6126e46101c3565b62461bcd60e51b8152806126fa600482016126bc565b0390fd5b61272d906127288161272161271b6127166000611bba565b610476565b91610476565b14156126d5565b612cc1565b565b61273890612641565b565b612742610f4f565b5061275c6127566301ffc9a760e01b6101d8565b916101d8565b1490565b6127729061276c612837565b9061307c565b565b90612789612784612790926123f3565b6123ff565b8254612381565b9055565b6127a86127a2828490611c76565b15610227565b6127b1575b5050565b6127d460016127cf60006127c760fb8690610f99565b018590611c37565b612774565b906127dd612837565b9061281a61281461280e7f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d95610e4a565b92611c2b565b92611c2b565b926128236101c3565b8061282d816104d4565b0390a438806127ad565b61283f611be4565b503390565b61284f818390611c76565b612858575b5050565b61287b6000612876600061286e60fb8690610f99565b018590611c37565b612774565b90612884612837565b906128c16128bb6128b57ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b95610e4a565b92611c2b565b92611c2b565b926128ca6101c3565b806128d4816104d4565b0390a43880612854565b6128e6611be4565b5061290260006128fc6128f761168e565b613115565b01611c08565b90565b5061290e612c72565b565b61291990612905565b565b90565b61293261292d6129379261291b565b61094d565b610374565b90565b6129637f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd914361291e565b90565b61296f906102e8565b90565b61297b90612966565b90565b61298790610304565b90565b906020828203126129a4576129a1916000016117c2565b90565b6101ce565b60207f6961626c65555549440000000000000000000000000000000000000000000000917f45524331393637557067726164653a20756e737570706f727465642070726f7860008201520152565b612a04602960409261102c565b612a0d816129a9565b0190565b612a2790602081019060008183039101526129f7565b90565b15612a3157565b612a396101c3565b62461bcd60e51b815280612a4f60048201612a11565b0390fd5b60207f6f6e206973206e6f742055555053000000000000000000000000000000000000917f45524331393637557067726164653a206e657720696d706c656d656e7461746960008201520152565b612aae602e60409261102c565b612ab781612a53565b0190565b612ad19060208101906000818303910152612aa1565b90565b91612af06000612aea612ae561293a565b613118565b01611c69565b600014612b05575050612b029061321b565b5b565b612b316020612b1b612b1686612972565b61297e565b6352d1902d90612b296101c3565b938492611716565b82528180612b41600482016104d4565b03915afa8091600092612bbf575b5015600014612b9357506001612b7157612b6c925b91909161311f565b612b03565b612b796101c3565b62461bcd60e51b815280612b8f60048201612abb565b0390fd5b92612bba612b6c94612bb4612bae612ba961168e565b610374565b91610374565b14612a2a565b612b64565b612be191925060203d8111612be8575b612bd981836105f1565b81019061298a565b9038612b4f565b503d612bcf565b60007f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572910152565b612c236020809261102c565b612c2c81612bef565b0190565b612c469060208101906000818303910152612c17565b90565b15612c5057565b612c586101c3565b62461bcd60e51b815280612c6e60048201612c30565b0390fd5b612c9c612c7d611c15565b612c96612c90612c8b612837565b610476565b91610476565b14612c49565b565b90565b90612cb6612cb1612cbd92611c2b565b612c9e565b82546113c7565b9055565b612ccb6097611c08565b612cd6826097612ca1565b90612d0a612d047f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e093611c2b565b91611c2b565b91612d136101c3565b80612d1d816104d4565b0390a3565b9050612d2c611e83565b50612d35611e83565b50013560f81c90565b612d46610f4f565b503b612d5b612d556000611301565b91610727565b1190565b60207f6e697469616c697a696e67000000000000000000000000000000000000000000917f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960008201520152565b612dba602b60409261102c565b612dc381612d5f565b0190565b612ddd9060208101906000818303910152612dad565b90565b15612de757565b612def6101c3565b62461bcd60e51b815280612e0560048201612dc7565b0390fd5b612e1b612e166000612278565b612de0565b612e23612e25565b565b612e2d613278565b565b612e37612e09565b565b612e4b612e466000612278565b612de0565b565b612e55612e39565b565b612e6090610e6e565b90565b90612e78612e73612e7f92610e4a565b612e57565b8254611506565b9055565b90612e8d82610fd5565b91612ea6826001612ea060fb8590610f99565b01612e63565b91612ee3612edd612ed77fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff95610e4a565b92610e4a565b92610e4a565b92612eec6101c3565b80612ef6816104d4565b0390a4565b612f07612f0c91610e6e565b61151d565b90565b90565b612f26612f21612f2b92612f0f565b6102e5565b610727565b90565b905090565b60007f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000910152565b612f6760178092612f2e565b612f7081612f33565b0190565b5190565b60005b838110612f8c575050906000910152565b806020918301518185015201612f7b565b612fc2612fb992602092612fb081612f74565b94858093612f2e565b93849101612f78565b0190565b60007f206973206d697373696e6720726f6c6520000000000000000000000000000000910152565b612ffa60118092612f2e565b61300381612fc6565b0190565b61302161302c939261301b61302693612f5b565b90612f9d565b612fee565b90612f9d565b90565b90565b61305161305a60209361305f9361304881612f74565b9384809361102c565b95869101612f78565b6105d1565b0190565b6130799160208201916000818403910152613032565b90565b9061309161308b838390611c76565b15610227565b613099575050565b613111916130ef6130c86130b86130b26130f4956132db565b93612efb565b6130c26020612f12565b906134cc565b916130e06130d46101c3565b93849260208401613007565b602082018103825203826105f1565b61302f565b6130fc6101c3565b91829162461bcd60e51b835260048301613063565b0390fd5b90565b90565b5190565b9161312983613618565b6131328261311b565b61314561313f6000611301565b91610727565b11908115613169575b50613158575b5050565b61316191613714565b503880613154565b90503861314e565b60207f6f74206120636f6e747261637400000000000000000000000000000000000000917f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60008201520152565b6131cc602d60409261102c565b6131d581613171565b0190565b6131ef90602081019060008183039101526131bf565b90565b156131f957565b6132016101c3565b62461bcd60e51b815280613217600482016131d9565b0390fd5b6132489061323061322b82612d3e565b6131f2565b600061324261323d61168e565b613115565b01612ca1565b565b61325c6132576000612278565b612de0565b613264613266565b565b613276613271612837565b612cc1565b565b61328061324a565b565b606090565b613290906102e8565b90565b6132a76132a26132ac926102da565b6102e5565b610727565b90565b90565b6132c66132c16132cb926132af565b6102e5565b611925565b90565b6132d860146132b2565b90565b6132f86132f361330e926132ed613282565b50613287565b613293565b6133086133036132ce565b61194b565b906134cc565b90565b90565b61332861332361332d92613311565b6102e5565b610727565b90565b61333f61334591939293610727565b92610727565b820180921161335057565b611d87565b600360fc1b90565b906133678261311b565b81101561337957600160209102010190565b611967565b600f60fb1b90565b61339a61339561339f926122ac565b6102e5565b610727565b90565b6133ab90610727565b600081146133ba576001900390565b611d87565b6f181899199a1a9b1b9c1cb0b131b232b360811b90565b6133de6133bf565b90565b90565b6133f86133f36133fd926133e1565b6102e5565b610727565b90565b60f81b90565b61341a61341561341f92611d68565b6102e5565b611925565b90565b6134419061343b61343561344694611925565b91610727565b90610294565b610727565b90565b60007f537472696e67733a20686578206c656e67746820696e73756666696369656e74910152565b61347d6020809261102c565b61348681613449565b0190565b6134a09060208101906000818303910152613471565b90565b156134aa57565b6134b26101c3565b62461bcd60e51b8152806134c86004820161348a565b0390fd5b91906134d6613282565b5061357061356061350c6135076134f760026134f28791613314565b611d9d565b6135016002613314565b90613330565b611339565b92613515613355565b61352e8561352860009360001a93611301565b9061335d565b5361353761337e565b6135508561354a60019360001a93613386565b9061335d565b5361355b6002613314565b611d9d565b61356a6001613386565b90613330565b925b836135866135806001613386565b91610727565b11156135ed576135946133d6565b8161359f600f6133e4565b169160108310156135e8576135bb6135dc926135e2941a613400565b6135cb8591889060001a9261335d565b536135d66004613406565b90613422565b936133a2565b92613572565b611967565b6136159293506136109061360a6136046000611301565b91610727565b146134a3565b61302f565b90565b6136218161321b565b61364b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b91611c2b565b906136546101c3565b8061365e816104d4565b0390a2565b606090565b67ffffffffffffffff8111613686576136826020916105d1565b0190565b6105db565b9061369d61369883613668565b61061a565b918252565b60207f206661696c656400000000000000000000000000000000000000000000000000917f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c60008201520152565b6136fa602761368b565b90613707602083016136a2565b565b6137116136f0565b90565b9061373191613721613663565b509061372b613709565b9161375f565b90565b3d600014613751576137453d61131d565b903d6000602084013e5b565b613759613663565b9061374f565b909160008061378f94613770613663565b508490602081019051915af491613785613734565b9092909192613816565b90565b60007f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000910152565b6137c7601d60209261102c565b6137d081613792565b0190565b6137ea90602081019060008183039101526137ba565b90565b156137f457565b6137fc6101c3565b62461bcd60e51b815280613812600482016137d4565b0390fd5b919290613821613663565b5060001461386757506138338261311b565b6138466138406000611301565b91610727565b14613850575b5090565b61385c61386191612d3e565b6137ed565b3861384c565b82906138728261311b565b61388561387f6000611301565b91610727565b116000146138965750805190602001fd5b6138b7906138a26101c3565b91829162461bcd60e51b835260048301613063565b0390fdfea26469706673582212206c2f16e02c565f760e831c27c0daa000c8a7a04aa98feb2406cbe087fc6dc3f264736f6c634300081c0033
Deployed Bytecode
0x60806040526004361015610013575b610f4a565b61001e6000356101bd565b806301ffc9a7146101b85780630a88a71b146101b3578063248a9ca3146101ae5780632a0acc6a146101a95780632f2ff15d146101a457806336568abe1461019f5780633659cfe61461019a57806349588dd8146101955780634f1ef28614610190578063505649451461018b57806352d1902d14610186578063607563b414610181578063715018a61461017c5780638da5cb5b1461017757806391d1485414610172578063a217fddf1461016d578063a86d0d7614610168578063b228abee14610163578063c7097a9c1461015e578063cd6dc68714610159578063d547741f14610154578063dbfbe5da1461014f578063e17efd481461014a578063ea5a3ec914610145578063f0f0fce9146101405763f2fde38b0361000e57610f17565b610ee1565b610e15565b610da6565b610d71565b610d0e565b610cda565b610c76565b610c27565b610b79565b610987565b610914565b6108df565b610889565b610855565b6107a0565b61076d565b6106fd565b610594565b610561565b61050e565b6104da565b610441565b6103dd565b61033f565b61024f565b60e01c90565b60405190565b600080fd5b600080fd5b600080fd5b63ffffffff60e01b1690565b6101ed816101d8565b036101f457565b600080fd5b90503590610206826101e4565b565b906020828203126102225761021f916000016101f9565b90565b6101ce565b151590565b61023590610227565b9052565b919061024d9060006020850194019061022c565b565b3461027f5761027b61026a610265366004610208565b610f54565b6102726101c3565b91829182610239565b0390f35b6101c9565b600091031261028f57565b6101ce565b1c90565b60018060a01b031690565b6102b39060086102b89302610294565b610298565b90565b906102c691546102a3565b90565b6102d761012e6000906102bb565b90565b60018060a01b031690565b90565b6102fc6102f7610301926102da565b6102e5565b6102da565b90565b61030d906102e8565b90565b61031990610304565b90565b61032590610310565b9052565b919061033d9060006020850194019061031c565b565b3461036f5761034f366004610284565b61036b61035a6102c9565b6103626101c3565b91829182610329565b0390f35b6101c9565b90565b61038081610374565b0361038757565b600080fd5b9050359061039982610377565b565b906020828203126103b5576103b29160000161038c565b90565b6101ce565b6103c390610374565b9052565b91906103db906000602085019401906103ba565b565b3461040d576104096103f86103f336600461039b565b610fd5565b6104006101c3565b918291826103c7565b0390f35b6101c9565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4290565b61043e610412565b90565b3461047157610451366004610284565b61046d61045c610436565b6104646101c3565b918291826103c7565b0390f35b6101c9565b61047f906102da565b90565b61048b81610476565b0361049257565b600080fd5b905035906104a482610482565b565b91906040838203126104cf57806104c36104cc926000860161038c565b93602001610497565b90565b6101ce565b60000190565b34610509576104f36104ed3660046104a6565b90611020565b6104fb6101c3565b80610505816104d4565b0390f35b6101c9565b3461053d576105276105213660046104a6565b906110df565b61052f6101c3565b80610539816104d4565b0390f35b6101c9565b9060208282031261055c5761055991600001610497565b90565b6101ce565b3461058f57610579610574366004610542565b611389565b6105816101c3565b8061058b816104d4565b0390f35b6101c9565b346105c2576105ac6105a7366004610542565b611427565b6105b46101c3565b806105be816104d4565b0390f35b6101c9565b600080fd5b600080fd5b601f801991011690565b634e487b7160e01b600052604160045260246000fd5b906105fb906105d1565b810190811067ffffffffffffffff82111761061557604052565b6105db565b9061062d6106266101c3565b92836105f1565b565b67ffffffffffffffff811161064d576106496020916105d1565b0190565b6105db565b90826000939282370152565b9092919261067361066e8261062f565b61061a565b9381855260208501908284011161068f5761068d92610652565b565b6105cc565b9080601f830112156106b2578160206106af9335910161065e565b90565b6105c7565b9190916040818403126106f8576106d18360008301610497565b92602082013567ffffffffffffffff81116106f3576106f09201610694565b90565b6101d3565b6101ce565b61071161070b3660046106b7565b906114df565b6107196101c3565b80610723816104d4565b0390f35b90565b61073381610727565b0361073a57565b600080fd5b9050359061074c8261072a565b565b90602082820312610768576107659160000161073f565b90565b6101ce565b3461079b5761078561078036600461074e565b61156a565b61078d6101c3565b80610797816104d4565b0390f35b6101c9565b346107d0576107b0366004610284565b6107cc6107bb6116c6565b6107c36101c3565b918291826103c7565b0390f35b6101c9565b600080fd5b600080fd5b909182601f830112156108195781359167ffffffffffffffff831161081457602001926001830284011161080f57565b6107da565b6107d5565b6105c7565b9060208282031261085057600082013567ffffffffffffffff811161084b5761084792016107df565b9091565b6101d3565b6101ce565b346108845761086e61086836600461081e565b90611b80565b6108766101c3565b80610880816104d4565b0390f35b6101c9565b346108b757610899366004610284565b6108a1611bda565b6108a96101c3565b806108b3816104d4565b0390f35b6101c9565b6108c590610476565b9052565b91906108dd906000602085019401906108bc565b565b3461090f576108ef366004610284565b61090b6108fa611c15565b6109026101c3565b918291826108c9565b0390f35b6101c9565b346109455761094161093061092a3660046104a6565b90611c76565b6109386101c3565b91829182610239565b0390f35b6101c9565b90565b60001b90565b61096761096261096c9261094a565b61094d565b610374565b90565b6109796000610953565b90565b61098461096f565b90565b346109b757610997366004610284565b6109b36109a261097c565b6109aa6101c3565b918291826103c7565b0390f35b6101c9565b67ffffffffffffffff81116109d45760208091020190565b6105db565b909291926109ee6109e9826109bc565b61061a565b9381855260208086019202830192818411610a2b57915b838310610a125750505050565b60208091610a20848661038c565b815201920191610a05565b6107da565b9080601f83011215610a4e57816020610a4b933591016109d9565b90565b6105c7565b9091604082840312610aad57600082013567ffffffffffffffff8111610aa85783610a7f9184016107df565b929093602082013567ffffffffffffffff8111610aa357610aa09201610a30565b90565b6101d3565b6101d3565b6101ce565b5190565b60209181520190565b60200190565b610ace90610727565b9052565b90602080610af693610aec60008201516000860190610ac5565b0151910190610ac5565b565b90610b0581604093610ad2565b0190565b60200190565b90610b2c610b26610b1f84610ab2565b8093610ab6565b92610abf565b9060005b818110610b3d5750505090565b909192610b56610b506001928651610af8565b94610b09565b9101919091610b30565b610b769160208201916000818403910152610b0f565b90565b610ba1610b90610b8a366004610a53565b91611ec3565b610b986101c3565b91829182610b60565b0390f35b91604083830312610be657600083013567ffffffffffffffff8111610be157610bd383610bde9286016107df565b93909460200161038c565b90565b6101d3565b6101ce565b90602080610c0f93610c0560008201516000860190610ac5565b0151910190610ac5565b565b9190610c2590600060408501940190610beb565b565b610c4f610c3e610c38366004610ba5565b916120f1565b610c466101c3565b91829182610c11565b0390f35b610c5c90610727565b9052565b9190610c7490600060208501940190610c53565b565b34610ca757610ca3610c92610c8c36600461081e565b9061221f565b610c9a6101c3565b91829182610c60565b0390f35b6101c9565b9190604083820312610cd55780610cc9610cd29260008601610497565b9360200161073f565b90565b6101ce565b34610d0957610cf3610ced366004610cac565b906125e0565b610cfb6101c3565b80610d05816104d4565b0390f35b6101c9565b34610d3d57610d27610d213660046104a6565b90612615565b610d2f6101c3565b80610d39816104d4565b0390f35b6101c9565b7fad312f08b8889cfe65ec2f1faae419f8b47f0153a3483ea6130918c055c8183d90565b610d6e610d42565b90565b34610da157610d81366004610284565b610d9d610d8c610d66565b610d946101c3565b918291826103c7565b0390f35b6101c9565b34610dd657610dd2610dc1610dbc36600461074e565b612621565b610dc96101c3565b91829182610c60565b0390f35b6101c9565b90565b610dee906008610df39302610294565b610ddb565b90565b90610e019154610dde565b90565b610e1261012d600090610df6565b90565b34610e4557610e25366004610284565b610e41610e30610e04565b610e386101c3565b91829182610c60565b0390f35b6101c9565b610e5390610374565b90565b90610e6090610e4a565b600052602052604060002090565b60001c90565b610e80610e8591610e6e565b610ddb565b90565b610e929054610e74565b90565b610ea19061012f610e56565b90610eba6001610eb360008501610e88565b9301610e88565b90565b916020610edf929493610ed860408201966000830190610c53565b0190610c53565b565b34610f1257610ef9610ef436600461039b565b610e95565b90610f0e610f056101c3565b92839283610ebd565b0390f35b6101c9565b34610f4557610f2f610f2a366004610542565b61272f565b610f376101c3565b80610f41816104d4565b0390f35b6101c9565b600080fd5b600090565b610f5c610f4f565b5080610f77610f71637965db0b60e01b6101d8565b916101d8565b14908115610f84575b5090565b610f8e915061273a565b38610f80565b600090565b90610fa390610e4a565b600052602052604060002090565b90565b610fc0610fc591610e6e565b610fb1565b90565b610fd29054610fb4565b90565b6001610fee610ff492610fe6610f94565b5060fb610f99565b01610fc8565b90565b906110129161100d61100882610fd5565b612760565b611014565b565b9061101e91612794565b565b9061102a91610ff7565b565b60209181520190565b60207f20726f6c657320666f722073656c660000000000000000000000000000000000917f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201520152565b611090602f60409261102c565b61109981611035565b0190565b6110b39060208101906000818303910152611083565b90565b156110bd57565b6110c56101c3565b62461bcd60e51b8152806110db6004820161109d565b0390fd5b9061110c91611107826111016110fb6110f6612837565b610476565b91610476565b146110b6565b612844565b565b61111790610304565b90565b60207f64656c656761746563616c6c0000000000000000000000000000000000000000917f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201520152565b611175602c60409261102c565b61117e8161111a565b0190565b6111989060208101906000818303910152611168565b90565b156111a257565b6111aa6101c3565b62461bcd60e51b8152806111c060048201611182565b0390fd5b60207f6163746976652070726f78790000000000000000000000000000000000000000917f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201520152565b61121f602c60409261102c565b611228816111c4565b0190565b6112429060208101906000818303910152611212565b90565b1561124c57565b6112546101c3565b62461bcd60e51b81528061126a6004820161122c565b0390fd5b6112ff906112b761127e3061110e565b6112b06112aa7f00000000000000000000000023298a30a3adfb9fc002a1fd013e59ac9c2124c1610476565b91610476565b141561119b565b6112fa6112c26128de565b6112f46112ee7f00000000000000000000000023298a30a3adfb9fc002a1fd013e59ac9c2124c1610476565b91610476565b14611245565b611360565b565b61131561131061131a9261094a565b6102e5565b610727565b90565b9061132f61132a8361062f565b61061a565b918252565b369037565b9061135e6113468361131d565b92602080611354869361062f565b9201910390611334565b565b6113879061136d81612910565b61137f61137a6000611301565b611339565b600091612ad4565b565b6113929061126e565b565b6113ad906113a86113a3610412565b612760565b611411565b565b6113b8906102e8565b90565b6113c4906113af565b90565b906113d860018060a01b039161094d565b9181191691161790565b6113eb906113af565b90565b90565b9061140661140161140d926113e2565b6113ee565b82546113c7565b9055565b61141d611425916113bb565b61012e6113f1565b565b61143090611394565b565b906114c49161147c6114433061110e565b61147561146f7f00000000000000000000000023298a30a3adfb9fc002a1fd013e59ac9c2124c1610476565b91610476565b141561119b565b6114bf6114876128de565b6114b96114b37f00000000000000000000000023298a30a3adfb9fc002a1fd013e59ac9c2124c1610476565b91610476565b14611245565b6114c6565b565b906114dd916114d481612910565b90600191612ad4565b565b906114e991611432565b565b611504906114ff6114fa610412565b612760565b61155c565b565b906115136000199161094d565b9181191691161790565b61153161152c61153692610727565b6102e5565b610727565b90565b90565b9061155161154c6115589261151d565b611539565b8254611506565b9055565b6115689061012d61153c565b565b611573906114eb565b565b60207f6c6564207468726f7567682064656c656761746563616c6c0000000000000000917f555550535570677261646561626c653a206d757374206e6f742062652063616c60008201520152565b6115d0603860409261102c565b6115d981611575565b0190565b6115f390602081019060008183039101526115c3565b90565b156115fd57565b6116056101c3565b62461bcd60e51b81528061161b600482016115dd565b0390fd5b61166c9061166761162f3061110e565b61166161165b7f00000000000000000000000023298a30a3adfb9fc002a1fd013e59ac9c2124c1610476565b91610476565b146115f6565b6116ba565b90565b90565b61168661168161168b9261166f565b61094d565b610374565b90565b6116b77f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc611672565b90565b506116c361168e565b90565b6116d66116d1610f94565b61161f565b90565b906116f3916116ee6116e9610d42565b612760565b6119ed565b565b61170161170691610e6e565b610298565b90565b61171390546116f5565b90565b60e01b90565b67ffffffffffffffff81116117345760208091020190565b6105db565b905051906117468261072a565b565b9092919261175d6117588261171c565b61061a565b938185526020808601920283019281841161179a57915b8383106117815750505050565b6020809161178f8486611739565b815201920191611774565b6107da565b9080601f830112156117bd578160206117ba93519101611748565b90565b6105c7565b905051906117cf82610377565b565b909291926117e66117e1826109bc565b61061a565b938185526020808601920283019281841161182357915b83831061180a5750505050565b6020809161181884866117c2565b8152019201916117fd565b6107da565b9080601f8301121561184657816020611843935191016117d1565b90565b6105c7565b916060838303126118c857600083015167ffffffffffffffff81116118c3578261187691850161179f565b92602081015167ffffffffffffffff81116118be578361189791830161179f565b92604082015167ffffffffffffffff81116118b9576118b69201611828565b90565b6101d3565b6101d3565b6101d3565b6101ce565b60209181520190565b91906118f0816118e9816118f5956118cd565b8095610652565b6105d1565b0190565b909161191192602083019260008185039101526118d6565b90565b61191c6101c3565b3d6000823e3d90fd5b60ff1690565b61193f61193a6119449261094a565b6102e5565b611925565b90565b5190565b61195f61195a61196492611925565b6102e5565b610727565b90565b634e487b7160e01b600052603260045260246000fd5b5190565b9061198b8261197d565b81101561199c576020809102010190565b611967565b6119ab9051610374565b90565b90565b906119bb82611947565b8110156119cc576020809102010190565b611967565b6119db9051610727565b90565b60016119ea9101611925565b90565b9190600090611a05611a0061012e611709565b610310565b611a27638331ed0f959295611a32611a1b6101c3565b97889586948594611716565b8452600484016118f9565b03915afa918215611b7b5760008080929094611b51575b50929092611a57600061192b565b5b80611a73611a6d611a6885611947565b610727565b9161194b565b1015611b4a57611af090611aac611aa761012f611aa1611a9c8a611a968761194b565b90611981565b6119a1565b90610e56565b6119ae565b611ab860018201610e88565b611ae4611ade611ad9611ad489611ace8861194b565b906119b1565b6119d1565b610727565b91610727565b10611af5575b506119de565b611a58565b611b4490611b20611b17611b1287611b0c8761194b565b906119b1565b6119d1565b6000830161153c565b6001611b3d611b3888611b328761194b565b906119b1565b6119d1565b910161153c565b38611aea565b5050509050565b915050611b729192503d806000833e611b6a81836105f1565b81019061184b565b90929138611a49565b611914565b90611b8a916116d9565b565b611b94612c72565b611b9c611bc6565b565b611bb2611bad611bb79261094a565b6102e5565b6102da565b90565b611bc390611b9e565b90565b611bd8611bd36000611bba565b612cc1565b565b611be2611b8c565b565b600090565b60018060a01b031690565b611c00611c0591610e6e565b611be9565b90565b611c129054611bf4565b90565b611c1d611be4565b50611c286097611c08565b90565b611c3490610304565b90565b90611c4190611c2b565b600052602052604060002090565b60ff1690565b611c61611c6691610e6e565b611c4f565b90565b611c739054611c55565b90565b611c9e916000611c93611c9993611c8b610f4f565b5060fb610f99565b01611c37565b611c69565b90565b606090565b67ffffffffffffffff8111611cbe5760208091020190565b6105db565b90611cd5611cd083611ca6565b61061a565b918252565b611ce4604061061a565b90565b600090565b611cf4611cda565b9060208083611d01611ce7565b815201611d0c611ce7565b81525050565b611d1a611cec565b90565b60005b828110611d2c57505050565b602090611d37611d12565b8184015201611d20565b90611d66611d4e83611cc3565b92602080611d5c8693611ca6565b9201910390611d1d565b565b90565b611d7f611d7a611d8492611d68565b6102e5565b610727565b90565b634e487b7160e01b600052601160045260246000fd5b611dac611db291939293610727565b92610727565b91611dbe838202610727565b928184041490151715611dcd57565b611d87565b60209181520190565b60200190565b611dea90610374565b9052565b90611dfb81602093611de1565b0190565b60200190565b90611e22611e1c611e158461197d565b8093611dd2565b92611ddb565b9060005b818110611e335750505090565b909192611e4c611e466001928651611dee565b94611dff565b9101919091611e26565b91611e809391611e7291604085019185830360008701526118d6565b916020818403910152611e05565b90565b600090565b611e92604061061a565b90565b90611e9f90610727565b9052565b90611ead82610ab2565b811015611ebe576020809102010190565b611967565b92919092611ecf611ca1565b50611ee1611edc8361197d565b611d41565b93611ef78282611ef16004611d6b565b91612d22565b611f27611f21611f1c3493611f16611f1061012d610e88565b9161194b565b90611d9d565b610727565b91610727565b1061207257600091611f65611f45611f4061012e611709565b610310565b91611f70631adb094a919496611f596101c3565b97889687958695611716565b855260048501611e56565b03915afa801561206d57600080929091612046575b5090611f8f611e83565b5b80611fab611fa5611fa086611947565b610727565b9161194b565b10156120415761203c90612035611fd3611fce85611fc88561194b565b906119b1565b6119d1565b612010611ff1611fec88611fe68761194b565b906119b1565b6119d1565b91612007611ffd611e88565b9360008501611e95565b60208301611e95565b61202f889184906120296120238361194b565b85611ea3565b5261194b565b90611ea3565b51506119de565b611f90565b505050565b905061206591503d806000833e61205d81836105f1565b81019061184b565b919091611f85565b611914565b600063a39c577b60e01b81528061208b600482016104d4565b0390fd5b612097611cec565b90565b91906040838203126120c357806120b76120c09260008601611739565b93602001611739565b90565b6101ce565b9392906120e76020916120ef94604088019188830360008a01526118d6565b9401906103ba565b565b906120fa61208f565b50612110828261210a6004611d6b565b91612d22565b61214061213a612135349361212f61212961012d610e88565b9161194b565b90611d9d565b610727565b91610727565b106121fd5760409161217e61215e61215961012e611709565b610310565b9161218963403664759194966121726101c3565b97889687958695611716565b8552600485016120c8565b03915afa80156121f8576000809290916121c5575b506121c290916121b96121af611e88565b9360008501611e95565b60208301611e95565b90565b6121c292506121eb915060403d81116121f1575b6121e381836105f1565b81019061209a565b9161219e565b503d6121d9565b611914565b600063a39c577b60e01b815280612216600482016104d4565b0390fd5b600090565b61225b916122419161222f61221a565b509061223b6004611d6b565b91612d22565b61225561224f61012d610e88565b9161194b565b90611d9d565b90565b60081c90565b6122706122759161225e565b611c4f565b90565b6122829054612264565b90565b60ff1690565b61229761229c91610e6e565b612285565b90565b6122a9905461228b565b90565b90565b6122c36122be6122c8926122ac565b6102e5565b611925565b90565b6122d490610304565b90565b60207f647920696e697469616c697a6564000000000000000000000000000000000000917f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160008201520152565b612332602e60409261102c565b61233b816122d7565b0190565b6123559060208101906000818303910152612325565b90565b1561235f57565b6123676101c3565b62461bcd60e51b81528061237d6004820161233f565b0390fd5b9061238d60ff9161094d565b9181191691161790565b6123ab6123a66123b092611925565b6102e5565b611925565b90565b90565b906123cb6123c66123d292612397565b6123b3565b8254612381565b9055565b60081b90565b906123e961ff00916123d6565b9181191691161790565b6123fc90610227565b90565b90565b9061241761241261241e926123f3565b6123ff565b82546123dc565b9055565b61242b906122af565b9052565b919061244390600060208501940190612422565b565b906124949061245d6124576000612278565b15610227565b928380612546575b80156124f7575b61247590612358565b61248961248260016122af565b60006123b6565b836124e6575b61256a565b61249b575b565b6124a6600080612402565b60016124de7f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498916124d56101c3565b9182918261242f565b0390a1612499565b6124f260016000612402565b61248f565b5061251261250c612507306122cb565b612d3e565b15610227565b8061251d575b61246c565b5061247561252b600061229f565b61253e61253860016122af565b91611925565b149050612518565b50612551600061229f565b61256461255e60016122af565b91611925565b10612465565b9061259261258a61259a9361257d612e2f565b612585612e4d565b6113bb565b61012e6113f1565b61012d61153c565b6125b36125a5610412565b6125ad610412565b90612e83565b6125cc6125be610d42565b6125c6610412565b90612e83565b6125de6125d7610412565b3390612794565b565b906125ea91612445565b565b90612607916126026125fd82610fd5565b612760565b612609565b565b9061261391612844565b565b9061261f916125ec565b565b61263e9061262d61221a565b5061263961012d610e88565b611d9d565b90565b6126529061264d612c72565b6126fe565b565b60207f6464726573730000000000000000000000000000000000000000000000000000917f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201520152565b6126af602660409261102c565b6126b881612654565b0190565b6126d290602081019060008183039101526126a2565b90565b156126dc57565b6126e46101c3565b62461bcd60e51b8152806126fa600482016126bc565b0390fd5b61272d906127288161272161271b6127166000611bba565b610476565b91610476565b14156126d5565b612cc1565b565b61273890612641565b565b612742610f4f565b5061275c6127566301ffc9a760e01b6101d8565b916101d8565b1490565b6127729061276c612837565b9061307c565b565b90612789612784612790926123f3565b6123ff565b8254612381565b9055565b6127a86127a2828490611c76565b15610227565b6127b1575b5050565b6127d460016127cf60006127c760fb8690610f99565b018590611c37565b612774565b906127dd612837565b9061281a61281461280e7f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d95610e4a565b92611c2b565b92611c2b565b926128236101c3565b8061282d816104d4565b0390a438806127ad565b61283f611be4565b503390565b61284f818390611c76565b612858575b5050565b61287b6000612876600061286e60fb8690610f99565b018590611c37565b612774565b90612884612837565b906128c16128bb6128b57ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b95610e4a565b92611c2b565b92611c2b565b926128ca6101c3565b806128d4816104d4565b0390a43880612854565b6128e6611be4565b5061290260006128fc6128f761168e565b613115565b01611c08565b90565b5061290e612c72565b565b61291990612905565b565b90565b61293261292d6129379261291b565b61094d565b610374565b90565b6129637f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd914361291e565b90565b61296f906102e8565b90565b61297b90612966565b90565b61298790610304565b90565b906020828203126129a4576129a1916000016117c2565b90565b6101ce565b60207f6961626c65555549440000000000000000000000000000000000000000000000917f45524331393637557067726164653a20756e737570706f727465642070726f7860008201520152565b612a04602960409261102c565b612a0d816129a9565b0190565b612a2790602081019060008183039101526129f7565b90565b15612a3157565b612a396101c3565b62461bcd60e51b815280612a4f60048201612a11565b0390fd5b60207f6f6e206973206e6f742055555053000000000000000000000000000000000000917f45524331393637557067726164653a206e657720696d706c656d656e7461746960008201520152565b612aae602e60409261102c565b612ab781612a53565b0190565b612ad19060208101906000818303910152612aa1565b90565b91612af06000612aea612ae561293a565b613118565b01611c69565b600014612b05575050612b029061321b565b5b565b612b316020612b1b612b1686612972565b61297e565b6352d1902d90612b296101c3565b938492611716565b82528180612b41600482016104d4565b03915afa8091600092612bbf575b5015600014612b9357506001612b7157612b6c925b91909161311f565b612b03565b612b796101c3565b62461bcd60e51b815280612b8f60048201612abb565b0390fd5b92612bba612b6c94612bb4612bae612ba961168e565b610374565b91610374565b14612a2a565b612b64565b612be191925060203d8111612be8575b612bd981836105f1565b81019061298a565b9038612b4f565b503d612bcf565b60007f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572910152565b612c236020809261102c565b612c2c81612bef565b0190565b612c469060208101906000818303910152612c17565b90565b15612c5057565b612c586101c3565b62461bcd60e51b815280612c6e60048201612c30565b0390fd5b612c9c612c7d611c15565b612c96612c90612c8b612837565b610476565b91610476565b14612c49565b565b90565b90612cb6612cb1612cbd92611c2b565b612c9e565b82546113c7565b9055565b612ccb6097611c08565b612cd6826097612ca1565b90612d0a612d047f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e093611c2b565b91611c2b565b91612d136101c3565b80612d1d816104d4565b0390a3565b9050612d2c611e83565b50612d35611e83565b50013560f81c90565b612d46610f4f565b503b612d5b612d556000611301565b91610727565b1190565b60207f6e697469616c697a696e67000000000000000000000000000000000000000000917f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960008201520152565b612dba602b60409261102c565b612dc381612d5f565b0190565b612ddd9060208101906000818303910152612dad565b90565b15612de757565b612def6101c3565b62461bcd60e51b815280612e0560048201612dc7565b0390fd5b612e1b612e166000612278565b612de0565b612e23612e25565b565b612e2d613278565b565b612e37612e09565b565b612e4b612e466000612278565b612de0565b565b612e55612e39565b565b612e6090610e6e565b90565b90612e78612e73612e7f92610e4a565b612e57565b8254611506565b9055565b90612e8d82610fd5565b91612ea6826001612ea060fb8590610f99565b01612e63565b91612ee3612edd612ed77fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff95610e4a565b92610e4a565b92610e4a565b92612eec6101c3565b80612ef6816104d4565b0390a4565b612f07612f0c91610e6e565b61151d565b90565b90565b612f26612f21612f2b92612f0f565b6102e5565b610727565b90565b905090565b60007f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000910152565b612f6760178092612f2e565b612f7081612f33565b0190565b5190565b60005b838110612f8c575050906000910152565b806020918301518185015201612f7b565b612fc2612fb992602092612fb081612f74565b94858093612f2e565b93849101612f78565b0190565b60007f206973206d697373696e6720726f6c6520000000000000000000000000000000910152565b612ffa60118092612f2e565b61300381612fc6565b0190565b61302161302c939261301b61302693612f5b565b90612f9d565b612fee565b90612f9d565b90565b90565b61305161305a60209361305f9361304881612f74565b9384809361102c565b95869101612f78565b6105d1565b0190565b6130799160208201916000818403910152613032565b90565b9061309161308b838390611c76565b15610227565b613099575050565b613111916130ef6130c86130b86130b26130f4956132db565b93612efb565b6130c26020612f12565b906134cc565b916130e06130d46101c3565b93849260208401613007565b602082018103825203826105f1565b61302f565b6130fc6101c3565b91829162461bcd60e51b835260048301613063565b0390fd5b90565b90565b5190565b9161312983613618565b6131328261311b565b61314561313f6000611301565b91610727565b11908115613169575b50613158575b5050565b61316191613714565b503880613154565b90503861314e565b60207f6f74206120636f6e747261637400000000000000000000000000000000000000917f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60008201520152565b6131cc602d60409261102c565b6131d581613171565b0190565b6131ef90602081019060008183039101526131bf565b90565b156131f957565b6132016101c3565b62461bcd60e51b815280613217600482016131d9565b0390fd5b6132489061323061322b82612d3e565b6131f2565b600061324261323d61168e565b613115565b01612ca1565b565b61325c6132576000612278565b612de0565b613264613266565b565b613276613271612837565b612cc1565b565b61328061324a565b565b606090565b613290906102e8565b90565b6132a76132a26132ac926102da565b6102e5565b610727565b90565b90565b6132c66132c16132cb926132af565b6102e5565b611925565b90565b6132d860146132b2565b90565b6132f86132f361330e926132ed613282565b50613287565b613293565b6133086133036132ce565b61194b565b906134cc565b90565b90565b61332861332361332d92613311565b6102e5565b610727565b90565b61333f61334591939293610727565b92610727565b820180921161335057565b611d87565b600360fc1b90565b906133678261311b565b81101561337957600160209102010190565b611967565b600f60fb1b90565b61339a61339561339f926122ac565b6102e5565b610727565b90565b6133ab90610727565b600081146133ba576001900390565b611d87565b6f181899199a1a9b1b9c1cb0b131b232b360811b90565b6133de6133bf565b90565b90565b6133f86133f36133fd926133e1565b6102e5565b610727565b90565b60f81b90565b61341a61341561341f92611d68565b6102e5565b611925565b90565b6134419061343b61343561344694611925565b91610727565b90610294565b610727565b90565b60007f537472696e67733a20686578206c656e67746820696e73756666696369656e74910152565b61347d6020809261102c565b61348681613449565b0190565b6134a09060208101906000818303910152613471565b90565b156134aa57565b6134b26101c3565b62461bcd60e51b8152806134c86004820161348a565b0390fd5b91906134d6613282565b5061357061356061350c6135076134f760026134f28791613314565b611d9d565b6135016002613314565b90613330565b611339565b92613515613355565b61352e8561352860009360001a93611301565b9061335d565b5361353761337e565b6135508561354a60019360001a93613386565b9061335d565b5361355b6002613314565b611d9d565b61356a6001613386565b90613330565b925b836135866135806001613386565b91610727565b11156135ed576135946133d6565b8161359f600f6133e4565b169160108310156135e8576135bb6135dc926135e2941a613400565b6135cb8591889060001a9261335d565b536135d66004613406565b90613422565b936133a2565b92613572565b611967565b6136159293506136109061360a6136046000611301565b91610727565b146134a3565b61302f565b90565b6136218161321b565b61364b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b91611c2b565b906136546101c3565b8061365e816104d4565b0390a2565b606090565b67ffffffffffffffff8111613686576136826020916105d1565b0190565b6105db565b9061369d61369883613668565b61061a565b918252565b60207f206661696c656400000000000000000000000000000000000000000000000000917f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c60008201520152565b6136fa602761368b565b90613707602083016136a2565b565b6137116136f0565b90565b9061373191613721613663565b509061372b613709565b9161375f565b90565b3d600014613751576137453d61131d565b903d6000602084013e5b565b613759613663565b9061374f565b909160008061378f94613770613663565b508490602081019051915af491613785613734565b9092909192613816565b90565b60007f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000910152565b6137c7601d60209261102c565b6137d081613792565b0190565b6137ea90602081019060008183039101526137ba565b90565b156137f457565b6137fc6101c3565b62461bcd60e51b815280613812600482016137d4565b0390fd5b919290613821613663565b5060001461386757506138338261311b565b6138466138406000611301565b91610727565b14613850575b5090565b61385c61386191612d3e565b6137ed565b3861384c565b82906138728261311b565b61388561387f6000611301565b91610727565b116000146138965750805190602001fd5b6138b7906138a26101c3565b91829162461bcd60e51b835260048301613063565b0390fdfea26469706673582212206c2f16e02c565f760e831c27c0daa000c8a7a04aa98feb2406cbe087fc6dc3f264736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.