Overview
APE Balance
0 APE
APE Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
4620252 | 23 hrs ago | Contract Creation | 0 APE |
Loading...
Loading
Contract Name:
TrustedForwarder
Compiler Version
v0.8.19+commit.7dd6d404
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; /** * @title TrustedForwarder * @author Limit Break, Inc. * @notice TrustedForwarder is a generic message forwarder, which allows you to relay transactions to any contract and preserve the original sender. * The processor acts as a trusted proxy, which can be a way to limit interactions with your contract, or enforce certain conditions. */ contract TrustedForwarder is EIP712, Initializable, Ownable { error TrustedForwarder__CannotSetAppSignerToZeroAddress(); error TrustedForwarder__CannotSetOwnerToZeroAddress(); error TrustedForwarder__CannotUseWithoutSignature(); error TrustedForwarder__InvalidSignature(); error TrustedForwarder__SignerNotAuthorized(); struct SignatureECDSA { uint8 v; bytes32 r; bytes32 s; } // keccak256("AppSigner(bytes32 messageHash,address target,address sender)") bytes32 public constant APP_SIGNER_TYPEHASH = 0xc83d02443cc9e12c5d2faae8a9a36bf0112f5b4a8cce23c9277a0c68bf638762; address public signer; constructor() EIP712("TrustedForwarder", "1") {} /** * @notice Initializes the TrustedForwarder contract. * * @dev This should be called atomically with the clone of the contract to prevent bad actors from calling it. * @dev - Throws if the contract is already initialized * * @param owner The address to assign the owner role to. * @param appSigner The address to assign the app signer role to. */ function __TrustedForwarder_init(address owner, address appSigner) external initializer { if (owner == address(0)) { revert TrustedForwarder__CannotSetOwnerToZeroAddress(); } if (appSigner != address(0)) { signer = appSigner; } _transferOwnership(owner); } /** * @notice Forwards a message to a target contract, preserving the original sender. * @notice In the case the forwarder does not require a signature, this function should be used to save gas. * * @dev - Throws if the target contract reverts. * @dev - Throws if the target address has no code. * @dev - Throws if `signer` is not address(0). * * @param target The address of the contract to forward the message to. * @param message The calldata to forward. * * @return returnData The return data of the call to the target contract. */ function forwardCall(address target, bytes calldata message) external payable returns (bytes memory returnData) { address signerCache = signer; if (signerCache != address(0)) { revert TrustedForwarder__CannotUseWithoutSignature(); } bytes memory encodedData = _encodeERC2771Context(message, _msgSender()); assembly { let success := call(gas(), target, callvalue(), add(encodedData, 0x20), mload(encodedData), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) mstore(0x40, add(add(returnData, 0x20), size)) // Adjust memory pointer returndatacopy(add(returnData, 0x20), 0, size) // Copy returndata to memory if iszero(success) { revert(add(returnData, 0x20), size) // Revert with return data on failure } // If the call was successful, but the return data is empty, check if the target address has code if iszero(size) { if iszero(extcodesize(target)) { mstore(0x00, 0x39bf07c1) // Store function selector `TrustedForwarder__TargetAddressHasNoCode()` and revert revert(0x1c, 0x04) // Revert with the custom function selector } } } } /** * @notice Forwards a message to a target contract, preserving the original sender. * @notice This should only be used if the forwarder requires a signature. * @notice In the case the app signer is not set, use the overloaded `forwardCall` function without a signature variable. * * @dev - Throws if the target contract reverts. * @dev - Throws if the target address has no code. * @dev - Throws if `signer` is not address(0) and the signature does not match the signer. * * @param target The address of the contract to forward the message to. * @param message The calldata to forward. * @param signature The signature of the message. * * @return returnData The return data of the call to the target contract. */ function forwardCall(address target, bytes calldata message, SignatureECDSA calldata signature) external payable returns (bytes memory returnData) { address signerCache = signer; if (signerCache != address(0)) { if ( signerCache != _ecdsaRecover( _hashTypedDataV4( keccak256(abi.encode(APP_SIGNER_TYPEHASH, keccak256(message), target, _msgSender())) ), signature.v, signature.r, signature.s ) ) { revert TrustedForwarder__SignerNotAuthorized(); } } bytes memory encodedData = _encodeERC2771Context(message, _msgSender()); assembly { let success := call(gas(), target, callvalue(), add(encodedData, 0x20), mload(encodedData), 0, 0) let size := returndatasize() returnData := mload(0x40) mstore(returnData, size) mstore(0x40, add(add(returnData, 0x20), size)) // Adjust memory pointer returndatacopy(add(returnData, 0x20), 0, size) // Copy returndata to memory if iszero(success) { revert(add(returnData, 0x20), size) // Revert with return data on failure } // If the call was successful, but the return data is empty, check if the target address has code if iszero(size) { if iszero(extcodesize(target)) { mstore(0x00, 0x39bf07c1) // Store function selector `TrustedForwarder__TargetAddressHasNoCode()` and revert revert(0x1c, 0x04) // Revert with the custom function selector } } } } /** * @notice Updates the app signer address. To disable app signing, set signer to address(0). * * @dev - Throws if the sender is not the owner. * * @param signer_ The address to assign the app signer role to. */ function updateSigner(address signer_) external onlyOwner { if (signer_ == address(0)) { revert TrustedForwarder__CannotSetAppSignerToZeroAddress(); } signer = signer_; } /** * @notice Resets the app signer address to address(0). * * @dev - Throws if the sender is not the owner. */ function deactivateSigner() external onlyOwner { signer = address(0); } /** * @notice Returns the domain separator used in the permit signature * * @return The domain separator */ function domainSeparatorV4() external view returns (bytes32) { return _domainSeparatorV4(); } /// @dev appends the msg.sender to the end of the calldata function _encodeERC2771Context(bytes calldata _data, address _msgSender) internal pure returns (bytes memory encodedData) { assembly { // Calculate total length: data.length + 20 bytes for the address let totalLength := add(_data.length, 20) // Allocate memory for the combined data encodedData := mload(0x40) mstore(0x40, add(encodedData, add(totalLength, 0x20))) // Set the length of the `encodedData` mstore(encodedData, totalLength) // Copy the `bytes calldata` data calldatacopy(add(encodedData, 0x20), _data.offset, _data.length) // Append the `address`. Addresses are 20 bytes, stored in the last 20 bytes of a 32-byte word mstore(add(add(encodedData, 0x20), _data.length), shl(96, _msgSender)) } } /** * @notice Recovers an ECDSA signature * * @dev This function is copied from OpenZeppelin's ECDSA library * * @param digest The digest to recover * @param v The v component of the signature * @param r The r component of the signature * @param s The s component of the signature * * @return recoveredSigner The signer of the digest */ function _ecdsaRecover(bytes32 digest, uint8 v, bytes32 r, bytes32 s) internal pure returns (address recoveredSigner) { if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { revert TrustedForwarder__InvalidSignature(); } recoveredSigner = ecrecover(digest, v, r, s); if (recoveredSigner == address(0)) { revert TrustedForwarder__InvalidSignature(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.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 Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.0; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/Address.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) || (!Address.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) (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 v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol) pragma solidity ^0.8.8; import "./StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(_FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// 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: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.8; import "./ECDSA.sol"; import "../ShortStrings.sol"; import "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * _Available since v3.4._ * * @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {EIP-5267}. * * _Available since v4.9._ */ function eip712Domain() public view virtual override returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _name.toStringWithFallback(_nameFallback), _version.toStringWithFallback(_versionFallback), block.chainid, address(this), bytes32(0), new uint256[](0) ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
{ "remappings": [ "forge-std/=lib/forge-std/src/", "@openzeppelin/=lib/openzeppelin-contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "openzeppelin/=lib/openzeppelin-contracts/contracts/" ], "optimizer": { "enabled": true, "runs": 1000000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"TrustedForwarder__CannotSetAppSignerToZeroAddress","type":"error"},{"inputs":[],"name":"TrustedForwarder__CannotSetOwnerToZeroAddress","type":"error"},{"inputs":[],"name":"TrustedForwarder__CannotUseWithoutSignature","type":"error"},{"inputs":[],"name":"TrustedForwarder__InvalidSignature","type":"error"},{"inputs":[],"name":"TrustedForwarder__SignerNotAuthorized","type":"error"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","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"},{"inputs":[],"name":"APP_SIGNER_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"appSigner","type":"address"}],"name":"__TrustedForwarder_init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deactivateSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"domainSeparatorV4","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"forwardCall","outputs":[{"internalType":"bytes","name":"returnData","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"message","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct TrustedForwarder.SignatureECDSA","name":"signature","type":"tuple"}],"name":"forwardCall","outputs":[{"internalType":"bytes","name":"returnData","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"signer_","type":"address"}],"name":"updateSigner","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6101606040523480156200001257600080fd5b50604080518082018252601081526f2a393ab9ba32b22337b93bb0b93232b960811b602080830191909152825180840190935260018352603160f81b90830152906200006082600062000119565b610120526200007181600162000119565b61014052815160208084019190912060e052815190820120610100524660a052620000ff60e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c052620001133362000152565b620003e0565b600060208351101562000139576200013183620001ae565b90506200014c565b816200014684826200029f565b5060ff90505b92915050565b600280546001600160a01b038381166201000081810262010000600160b01b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080829050601f81511115620001e5578260405163305a27a960e01b8152600401620001dc91906200036b565b60405180910390fd5b8051620001f282620003bb565b179392505050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200022557607f821691505b6020821081036200024657634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200029a57600081815260208120601f850160051c81016020861015620002755750805b601f850160051c820191505b81811015620002965782815560010162000281565b5050505b505050565b81516001600160401b03811115620002bb57620002bb620001fa565b620002d381620002cc845462000210565b846200024c565b602080601f8311600181146200030b5760008415620002f25750858301515b600019600386901b1c1916600185901b17855562000296565b600085815260208120601f198616915b828110156200033c578886015182559484019460019091019084016200031b565b50858210156200035b5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083528351808285015260005b818110156200039a578581018301518582016040015282016200037c565b506000604082860101526040601f19601f8301168501019250505092915050565b80516020808301519190811015620002465760001960209190910360031b1b16919050565b60805160a05160c05160e05161010051610120516101405161122d6200043b60003960006105ef015260006105c501526000610ba001526000610b7801526000610ad301526000610afd01526000610b27015261122d6000f3fe6080604052600436106100c75760003560e01c806384b0196e11610074578063be018c971161004e578063be018c971461024e578063d45381ed14610261578063f2fde38b1461027657600080fd5b806384b0196e146101d55780638da5cb5b146101fd578063a7ecd37e1461022e57600080fd5b8063715018a6116100a5578063715018a61461018957806378e890ba146101a057806381ab13d7146101b557600080fd5b806322bee494146100cc578063238ac933146100f557806340c0494214610147575b600080fd5b6100df6100da366004610f07565b610296565b6040516100ec9190610fbe565b60405180910390f35b34801561010157600080fd5b506003546101229073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100ec565b34801561015357600080fd5b5061017b7fc83d02443cc9e12c5d2faae8a9a36bf0112f5b4a8cce23c9277a0c68bf63876281565b6040519081526020016100ec565b34801561019557600080fd5b5061019e610350565b005b3480156101ac57600080fd5b5061017b610364565b3480156101c157600080fd5b5061019e6101d0366004610fd8565b610373565b3480156101e157600080fd5b506101ea6105b7565b6040516100ec979695949392919061100b565b34801561020957600080fd5b5060025462010000900473ffffffffffffffffffffffffffffffffffffffff16610122565b34801561023a57600080fd5b5061019e6102493660046110ca565b61065b565b6100df61025c3660046110e5565b6106f7565b34801561026d57600080fd5b5061019e61089d565b34801561028257600080fd5b5061019e6102913660046110ca565b6108cf565b60035460609073ffffffffffffffffffffffffffffffffffffffff1680156102ea576040517faa7e8c5c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006102f7858533610986565b9050600080825160208401348a5af13d6040519450808552806020860101604052806000602087013e8161032c578060208601fd5b8061034557873b610345576339bf07c16000526004601cfd5b505050509392505050565b6103586109b2565b6103626000610a3a565b565b600061036e610ab9565b905090565b600254610100900460ff16158080156103935750600254600160ff909116105b806103ad5750303b1580156103ad575060025460ff166001145b61043e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561049c57600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff83166104e9576040517f5a141e8300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82161561054657600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84161790555b61054f83610a3a565b80156105b257600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b6000606080828080836105ea7f000000000000000000000000000000000000000000000000000000000000000083610bf1565b6106157f00000000000000000000000000000000000000000000000000000000000000006001610bf1565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b6106636109b2565b73ffffffffffffffffffffffffffffffffffffffff81166106b0576040517f6c3348cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60035460609073ffffffffffffffffffffffffffffffffffffffff168015610836576107d26107b67fc83d02443cc9e12c5d2faae8a9a36bf0112f5b4a8cce23c9277a0c68bf63876260001b8787604051610753929190611171565b6040518091039020896107633390565b60408051602081019590955284019290925273ffffffffffffffffffffffffffffffffffffffff908116606084015216608082015260a00160405160208183030381529060405280519060200120610c9e565b6107c36020860186611181565b85602001358660400135610ce6565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610836576040517fccc0b10800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610843868633610986565b9050600080825160208401348b5af13d6040519450808552806020860101604052806000602087013e81610878578060208601fd5b8061089157883b610891576339bf07c16000526004601cfd5b50505050949350505050565b6108a56109b2565b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6108d76109b2565b73ffffffffffffffffffffffffffffffffffffffff811661097a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610435565b61098381610a3a565b50565b60408051808401603401909152601483018152828460208301378160601b836020830101529392505050565b60025473ffffffffffffffffffffffffffffffffffffffff62010000909104163314610362576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610435565b6002805473ffffffffffffffffffffffffffffffffffffffff838116620100008181027fffffffffffffffffffff0000000000000000000000000000000000000000ffff85161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148015610b1f57507f000000000000000000000000000000000000000000000000000000000000000046145b15610b4957507f000000000000000000000000000000000000000000000000000000000000000090565b61036e604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b606060ff8314610c0b57610c0483610e15565b9050610c98565b818054610c17906111a4565b80601f0160208091040260200160405190810160405280929190818152602001828054610c43906111a4565b8015610c905780601f10610c6557610100808354040283529160200191610c90565b820191906000526020600020905b815481529060010190602001808311610c7357829003601f168201915b505050505090505b92915050565b6000610c98610cab610ab9565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115610d42576040517f14e515c900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051600081526020810180835287905260ff861691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa158015610d95573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116610e0d576040517f14e515c900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b60606000610e2283610e54565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f811115610c98576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff81168114610eb957600080fd5b919050565b60008083601f840112610ed057600080fd5b50813567ffffffffffffffff811115610ee857600080fd5b602083019150836020828501011115610f0057600080fd5b9250929050565b600080600060408486031215610f1c57600080fd5b610f2584610e95565b9250602084013567ffffffffffffffff811115610f4157600080fd5b610f4d86828701610ebe565b9497909650939450505050565b6000815180845260005b81811015610f8057602081850181015186830182015201610f64565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081526000610fd16020830184610f5a565b9392505050565b60008060408385031215610feb57600080fd5b610ff483610e95565b915061100260208401610e95565b90509250929050565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e08184015261104760e084018a610f5a565b8381036040850152611059818a610f5a565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c0860152855180825283870192509083019060005b818110156110b85783518352928401929184019160010161109c565b50909c9b505050505050505050505050565b6000602082840312156110dc57600080fd5b610fd182610e95565b60008060008084860360a08112156110fc57600080fd5b61110586610e95565b9450602086013567ffffffffffffffff81111561112157600080fd5b61112d88828901610ebe565b90955093505060607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08201121561116357600080fd5b509295919450926040019150565b8183823760009101908152919050565b60006020828403121561119357600080fd5b813560ff81168114610fd157600080fd5b600181811c908216806111b857607f821691505b6020821081036111f1577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b5091905056fea26469706673582212201a35639d29974b59856ca49be40f91fbf936ddd20662399691a28130fcf55d2864736f6c63430008130033
Deployed Bytecode
0x6080604052600436106100c75760003560e01c806384b0196e11610074578063be018c971161004e578063be018c971461024e578063d45381ed14610261578063f2fde38b1461027657600080fd5b806384b0196e146101d55780638da5cb5b146101fd578063a7ecd37e1461022e57600080fd5b8063715018a6116100a5578063715018a61461018957806378e890ba146101a057806381ab13d7146101b557600080fd5b806322bee494146100cc578063238ac933146100f557806340c0494214610147575b600080fd5b6100df6100da366004610f07565b610296565b6040516100ec9190610fbe565b60405180910390f35b34801561010157600080fd5b506003546101229073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100ec565b34801561015357600080fd5b5061017b7fc83d02443cc9e12c5d2faae8a9a36bf0112f5b4a8cce23c9277a0c68bf63876281565b6040519081526020016100ec565b34801561019557600080fd5b5061019e610350565b005b3480156101ac57600080fd5b5061017b610364565b3480156101c157600080fd5b5061019e6101d0366004610fd8565b610373565b3480156101e157600080fd5b506101ea6105b7565b6040516100ec979695949392919061100b565b34801561020957600080fd5b5060025462010000900473ffffffffffffffffffffffffffffffffffffffff16610122565b34801561023a57600080fd5b5061019e6102493660046110ca565b61065b565b6100df61025c3660046110e5565b6106f7565b34801561026d57600080fd5b5061019e61089d565b34801561028257600080fd5b5061019e6102913660046110ca565b6108cf565b60035460609073ffffffffffffffffffffffffffffffffffffffff1680156102ea576040517faa7e8c5c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006102f7858533610986565b9050600080825160208401348a5af13d6040519450808552806020860101604052806000602087013e8161032c578060208601fd5b8061034557873b610345576339bf07c16000526004601cfd5b505050509392505050565b6103586109b2565b6103626000610a3a565b565b600061036e610ab9565b905090565b600254610100900460ff16158080156103935750600254600160ff909116105b806103ad5750303b1580156103ad575060025460ff166001145b61043e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561049c57600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff83166104e9576040517f5a141e8300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82161561054657600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84161790555b61054f83610a3a565b80156105b257600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b6000606080828080836105ea7f54727573746564466f727761726465720000000000000000000000000000001083610bf1565b6106157f31000000000000000000000000000000000000000000000000000000000000016001610bf1565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b6106636109b2565b73ffffffffffffffffffffffffffffffffffffffff81166106b0576040517f6c3348cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60035460609073ffffffffffffffffffffffffffffffffffffffff168015610836576107d26107b67fc83d02443cc9e12c5d2faae8a9a36bf0112f5b4a8cce23c9277a0c68bf63876260001b8787604051610753929190611171565b6040518091039020896107633390565b60408051602081019590955284019290925273ffffffffffffffffffffffffffffffffffffffff908116606084015216608082015260a00160405160208183030381529060405280519060200120610c9e565b6107c36020860186611181565b85602001358660400135610ce6565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610836576040517fccc0b10800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610843868633610986565b9050600080825160208401348b5af13d6040519450808552806020860101604052806000602087013e81610878578060208601fd5b8061089157883b610891576339bf07c16000526004601cfd5b50505050949350505050565b6108a56109b2565b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6108d76109b2565b73ffffffffffffffffffffffffffffffffffffffff811661097a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610435565b61098381610a3a565b50565b60408051808401603401909152601483018152828460208301378160601b836020830101529392505050565b60025473ffffffffffffffffffffffffffffffffffffffff62010000909104163314610362576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610435565b6002805473ffffffffffffffffffffffffffffffffffffffff838116620100008181027fffffffffffffffffffff0000000000000000000000000000000000000000ffff85161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ff000047abea9064c699c0727148776e4e17771c16148015610b1f57507f000000000000000000000000000000000000000000000000000000000000817346145b15610b4957507f4ee319cfcf8e674b61f51520b24b6eaecef63e394cdff12de02beabb5d6b905290565b61036e604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f1e77b7b1707ed3eeba1656486948f3a5888f9a036cd988404683ef7532dc340c918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b606060ff8314610c0b57610c0483610e15565b9050610c98565b818054610c17906111a4565b80601f0160208091040260200160405190810160405280929190818152602001828054610c43906111a4565b8015610c905780601f10610c6557610100808354040283529160200191610c90565b820191906000526020600020905b815481529060010190602001808311610c7357829003601f168201915b505050505090505b92915050565b6000610c98610cab610ab9565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115610d42576040517f14e515c900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051600081526020810180835287905260ff861691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa158015610d95573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116610e0d576040517f14e515c900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b60606000610e2283610e54565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f811115610c98576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803573ffffffffffffffffffffffffffffffffffffffff81168114610eb957600080fd5b919050565b60008083601f840112610ed057600080fd5b50813567ffffffffffffffff811115610ee857600080fd5b602083019150836020828501011115610f0057600080fd5b9250929050565b600080600060408486031215610f1c57600080fd5b610f2584610e95565b9250602084013567ffffffffffffffff811115610f4157600080fd5b610f4d86828701610ebe565b9497909650939450505050565b6000815180845260005b81811015610f8057602081850181015186830182015201610f64565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081526000610fd16020830184610f5a565b9392505050565b60008060408385031215610feb57600080fd5b610ff483610e95565b915061100260208401610e95565b90509250929050565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e08184015261104760e084018a610f5a565b8381036040850152611059818a610f5a565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c0860152855180825283870192509083019060005b818110156110b85783518352928401929184019160010161109c565b50909c9b505050505050505050505050565b6000602082840312156110dc57600080fd5b610fd182610e95565b60008060008084860360a08112156110fc57600080fd5b61110586610e95565b9450602086013567ffffffffffffffff81111561112157600080fd5b61112d88828901610ebe565b90955093505060607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08201121561116357600080fd5b509295919450926040019150565b8183823760009101908152919050565b60006020828403121561119357600080fd5b813560ff81168114610fd157600080fd5b600181811c908216806111b857607f821691505b6020821081036111f1577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b5091905056fea26469706673582212201a35639d29974b59856ca49be40f91fbf936ddd20662399691a28130fcf55d2864736f6c63430008130033
Deployed Bytecode Sourcemap
658:8843:12:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2734:1383;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;1292:21;;;;;;;;;;-1:-1:-1;1292:21:12;;;;;;;;;;;1939:42:13;1927:55;;;1909:74;;1897:2;1882:18;1292:21:12;1763:226:13;1174:112:12;;;;;;;;;;-1:-1:-1;1174:112:12;1220:66;1174:112;;;;;2140:25:13;;;2128:2;2113:18;1174:112:12;1994:177:13;1824:101:0;;;;;;;;;;;;;:::i;:::-;;7589:105:12;;;;;;;;;;;;;:::i;1790:324::-;;;;;;;;;;-1:-1:-1;1790:324:12;;;;;:::i;:::-;;:::i;5021:633:9:-;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;:::i;1201:85:0:-;;;;;;;;;;-1:-1:-1;1273:6:0;;;;;;;1201:85;;7012:210:12;;;;;;;;;;-1:-1:-1;7012:210:12;;;;;:::i;:::-;;:::i;4928:1827::-;;;;;;:::i;:::-;;:::i;7368:83::-;;;;;;;;;;;;;:::i;2074:198:0:-;;;;;;;;;;-1:-1:-1;2074:198:0;;;;;:::i;:::-;;:::i;2734:1383:12:-;2906:6;;2845:23;;2906:6;;2926:25;;2922:108;;2974:45;;;;;;;;;;;;;;2922:108;3040:24;3067:44;3089:7;;719:10:4;3067:21:12;:44::i;:::-;3040:71;;3239:1;3236;3222:11;3216:18;3209:4;3196:11;3192:22;3179:11;3171:6;3164:5;3159:82;3266:16;3316:4;3310:11;3296:25;;3353:4;3341:10;3334:24;3411:4;3404;3392:10;3388:21;3384:32;3378:4;3371:46;3496:4;3493:1;3486:4;3474:10;3470:21;3455:46;3554:7;3544:124;;3611:4;3604;3592:10;3588:21;3581:35;3544:124;3802:4;3792:309;;3848:6;3836:19;3826:261;;3892:10;3886:4;3879:24;4020:4;4014;4007:18;3826:261;3792:309;;3130:981;;2734:1383;;;;;:::o;1824:101:0:-;1094:13;:11;:13::i;:::-;1888:30:::1;1915:1;1888:18;:30::i;:::-;1824:101::o:0;7589:105:12:-;7641:7;7667:20;:18;:20::i;:::-;7660:27;;7589:105;:::o;1790:324::-;3291:13:2;;;;;;;3290:14;;3336:34;;;;-1:-1:-1;3354:12:2;;3369:1;3354:12;;;;:16;3336:34;3335:97;;;-1:-1:-1;3404:4:2;1702:19:3;:23;;;3376:55:2;;-1:-1:-1;3414:12:2;;;;;:17;3376:55;3314:190;;;;;;;4883:2:13;3314:190:2;;;4865:21:13;4922:2;4902:18;;;4895:30;4961:34;4941:18;;;4934:62;5032:16;5012:18;;;5005:44;5066:19;;3314:190:2;;;;;;;;;3514:12;:16;;;;3529:1;3514:16;;;3540:65;;;;3574:13;:20;;;;;;;;3540:65;1892:19:12::1;::::0;::::1;1888:104;;1934:47;;;;;;;;;;;;;;1888:104;2005:23;::::0;::::1;::::0;2001:72:::1;;2044:6;:18:::0;;;::::1;;::::0;::::1;;::::0;;2001:72:::1;2082:25;2101:5;2082:18;:25::i;:::-;3629:14:2::0;3625:99;;;3659:13;:21;;;;;;3699:14;;-1:-1:-1;5248:36:13;;3699:14:2;;5236:2:13;5221:18;3699:14:2;;;;;;;3625:99;3258:472;1790:324:12;;:::o;5021:633:9:-;5136:13;5163:18;;5136:13;;;5163:18;5427:41;:5;5136:13;5427:26;:41::i;:::-;5482:47;:8;5512:16;5482:29;:47::i;:::-;5621:16;;;5605:1;5621:16;;;;;;;;;5376:271;;;;-1:-1:-1;5376:271:9;;-1:-1:-1;5543:13:9;;-1:-1:-1;5578:4:9;;-1:-1:-1;5605:1:9;-1:-1:-1;5621:16:9;-1:-1:-1;5376:271:9;-1:-1:-1;5021:633:9:o;7012:210:12:-;1094:13:0;:11;:13::i;:::-;7084:21:12::1;::::0;::::1;7080:110;;7128:51;;;;;;;;;;;;;;7080:110;7199:6;:16:::0;;;::::1;;::::0;;;::::1;::::0;;;::::1;::::0;;7012:210::o;4928:1827::-;5135:6;;5074:23;;5135:6;;5155:25;;5151:517;;5236:328;5275:156;1220:66;5342:19;;5373:7;;5363:18;;;;;;;:::i;:::-;;;;;;;;5383:6;5391:12;719:10:4;;640:96;5391:12:12;5331:73;;;;;;5991:25:13;;;;6032:18;;6025:34;;;;6078:42;6156:15;;;6136:18;;;6129:43;6208:15;6188:18;;;6181:43;5963:19;;5331:73:12;;;;;;;;;;;;5321:84;;;;;;5275:16;:156::i;:::-;5457:11;;;;:9;:11;:::i;:::-;5494:9;:11;;;5531:9;:11;;;5236:13;:328::i;:::-;5221:343;;:11;:343;;;5196:462;;5604:39;;;;;;;;;;;;;;5196:462;5678:24;5705:44;5727:7;;719:10:4;3067:21:12;:44::i;5705:::-;5678:71;;5877:1;5874;5860:11;5854:18;5847:4;5834:11;5830:22;5817:11;5809:6;5802:5;5797:82;5904:16;5954:4;5948:11;5934:25;;5991:4;5979:10;5972:24;6049:4;6042;6030:10;6026:21;6022:32;6016:4;6009:46;6134:4;6131:1;6124:4;6112:10;6108:21;6093:46;6192:7;6182:124;;6249:4;6242;6230:10;6226:21;6219:35;6182:124;6440:4;6430:309;;6486:6;6474:19;6464:261;;6530:10;6524:4;6517:24;6658:4;6652;6645:18;6464:261;6430:309;;5768:981;;4928:1827;;;;;;:::o;7368:83::-;1094:13:0;:11;:13::i;:::-;7425:6:12::1;:19:::0;;;::::1;::::0;;7368:83::o;2074:198:0:-;1094:13;:11;:13::i;:::-;2162:22:::1;::::0;::::1;2154:73;;;::::0;::::1;::::0;;6711:2:13;2154:73:0::1;::::0;::::1;6693:21:13::0;6750:2;6730:18;;;6723:30;6789:34;6769:18;;;6762:62;6860:8;6840:18;;;6833:36;6886:19;;2154:73:0::1;6509:402:13::0;2154:73:0::1;2237:28;2256:8;2237:18;:28::i;:::-;2074:198:::0;:::o;7763:862:12:-;8125:4;8119:11;;8156:40;;;8173:22;8156:40;8143:54;;;8034:2;8016:21;;8262:32;;8020:12;8391;8190:4;8367:22;;8354:64;8597:10;8593:2;8589:19;8574:12;8567:4;8554:11;8550:22;8546:41;8539:70;7763:862;;;;;:::o;1359:130:0:-;1273:6;;1422:23;1273:6;;;;;719:10:4;1422:23:0;1414:68;;;;;;;7118:2:13;1414:68:0;;;7100:21:13;;;7137:18;;;7130:30;7196:34;7176:18;;;7169:62;7248:18;;1414:68:0;6916:356:13;2426:187:0;2518:6;;;;2534:17;;;2518:6;2534:17;;;;;;;;;;2566:40;;2518:6;;;;;;;;2566:40;;2499:16;;2566:40;2489:124;2426:187;:::o;3695:262:9:-;3748:7;3779:4;3771:28;3788:11;3771:28;;:63;;;;;3820:14;3803:13;:31;3771:63;3767:184;;;-1:-1:-1;3857:22:9;;3695:262::o;3767:184::-;3917:23;4054:81;;;1929:95;4054:81;;;8381:25:13;4077:11:9;8422:18:13;;;8415:34;;;;4090:14:9;8465:18:13;;;8458:34;4106:13:9;8508:18:13;;;8501:34;4129:4:9;8551:19:13;;;8544:84;4018:7:9;;8353:19:13;;4054:81:9;;;;;;;;;;;;4044:92;;;;;;4037:99;;3963:180;;3367:268:5;3461:13;1371:66;3490:47;;3486:143;;3560:15;3569:5;3560:8;:15::i;:::-;3553:22;;;;3486:143;3613:5;3606:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3486:143;3367:268;;;;:::o;4768:165:9:-;4845:7;4871:55;4893:20;:18;:20::i;:::-;4915:10;8536:4:8;8530:11;8566:10;8554:23;;8606:4;8597:14;;8590:39;;;;8658:4;8649:14;;8642:34;8712:4;8697:20;;;8336:397;9045:454:12;9138:23;9190:66;9177:79;;9173:153;;;9279:36;;;;;;;;;;;;;;9173:153;9354:26;;;;;;;;;;;;7946:25:13;;;8019:4;8007:17;;7987:18;;;7980:45;;;;8041:18;;;8034:34;;;8084:18;;;8077:34;;;9354:26:12;;7918:19:13;;9354:26:12;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;9354:26:12;;;;;;-1:-1:-1;;9394:29:12;;;9390:103;;9446:36;;;;;;;;;;;;;;9390:103;9045:454;;;;;;:::o;2059:405:5:-;2118:13;2143:11;2157:16;2168:4;2157:10;:16::i;:::-;2281:14;;;2292:2;2281:14;;;;;;;;;2143:30;;-1:-1:-1;2261:17:5;;2281:14;;;;;;;;;-1:-1:-1;;;2371:16:5;;;-1:-1:-1;2416:4:5;2407:14;;2400:28;;;;-1:-1:-1;2371:16:5;2059:405::o;2536:245::-;2597:7;2669:4;2633:40;;2696:2;2687:11;;2683:69;;;2721:20;;;;;;;;;;;;;;14:196:13;82:20;;142:42;131:54;;121:65;;111:93;;200:1;197;190:12;111:93;14:196;;;:::o;215:347::-;266:8;276:6;330:3;323:4;315:6;311:17;307:27;297:55;;348:1;345;338:12;297:55;-1:-1:-1;371:20:13;;414:18;403:30;;400:50;;;446:1;443;436:12;400:50;483:4;475:6;471:17;459:29;;535:3;528:4;519:6;511;507:19;503:30;500:39;497:59;;;552:1;549;542:12;497:59;215:347;;;;;:::o;567:483::-;646:6;654;662;715:2;703:9;694:7;690:23;686:32;683:52;;;731:1;728;721:12;683:52;754:29;773:9;754:29;:::i;:::-;744:39;;834:2;823:9;819:18;806:32;861:18;853:6;850:30;847:50;;;893:1;890;883:12;847:50;932:58;982:7;973:6;962:9;958:22;932:58;:::i;:::-;567:483;;1009:8;;-1:-1:-1;906:84:13;;-1:-1:-1;;;;567:483:13:o;1055:481::-;1096:3;1134:5;1128:12;1161:6;1156:3;1149:19;1186:1;1196:162;1210:6;1207:1;1204:13;1196:162;;;1272:4;1328:13;;;1324:22;;1318:29;1300:11;;;1296:20;;1289:59;1225:12;1196:162;;;1200:3;1403:1;1396:4;1387:6;1382:3;1378:16;1374:27;1367:38;1525:4;1455:66;1450:2;1442:6;1438:15;1434:88;1429:3;1425:98;1421:109;1414:116;;;1055:481;;;;:::o;1541:217::-;1688:2;1677:9;1670:21;1651:4;1708:44;1748:2;1737:9;1733:18;1725:6;1708:44;:::i;:::-;1700:52;1541:217;-1:-1:-1;;;1541:217:13:o;2176:260::-;2244:6;2252;2305:2;2293:9;2284:7;2280:23;2276:32;2273:52;;;2321:1;2318;2311:12;2273:52;2344:29;2363:9;2344:29;:::i;:::-;2334:39;;2392:38;2426:2;2415:9;2411:18;2392:38;:::i;:::-;2382:48;;2176:260;;;;;:::o;2441:1333::-;2838:66;2830:6;2826:79;2815:9;2808:98;2789:4;2925:2;2963:3;2958:2;2947:9;2943:18;2936:31;2990:45;3030:3;3019:9;3015:19;3007:6;2990:45;:::i;:::-;3083:9;3075:6;3071:22;3066:2;3055:9;3051:18;3044:50;3117:32;3142:6;3134;3117:32;:::i;:::-;3180:2;3165:18;;3158:34;;;3241:42;3229:55;;3223:3;3208:19;;3201:84;3316:3;3301:19;;3294:35;;;3366:22;;;3360:3;3345:19;;3338:51;3438:13;;3460:22;;;3536:15;;;;-1:-1:-1;3498:15:13;;;;-1:-1:-1;3579:169:13;3593:6;3590:1;3587:13;3579:169;;;3654:13;;3642:26;;3723:15;;;;3688:12;;;;3615:1;3608:9;3579:169;;;-1:-1:-1;3765:3:13;;2441:1333;-1:-1:-1;;;;;;;;;;;;2441:1333:13:o;3779:186::-;3838:6;3891:2;3879:9;3870:7;3866:23;3862:32;3859:52;;;3907:1;3904;3897:12;3859:52;3930:29;3949:9;3930:29;:::i;3970:706::-;4092:6;4100;4108;4116;4160:9;4151:7;4147:23;4190:3;4186:2;4182:12;4179:32;;;4207:1;4204;4197:12;4179:32;4230:29;4249:9;4230:29;:::i;:::-;4220:39;;4310:2;4299:9;4295:18;4282:32;4337:18;4329:6;4326:30;4323:50;;;4369:1;4366;4359:12;4323:50;4408:58;4458:7;4449:6;4438:9;4434:22;4408:58;:::i;:::-;4485:8;;-1:-1:-1;4382:84:13;-1:-1:-1;;4613:2:13;4544:66;4536:75;;4532:84;4529:104;;;4629:1;4626;4619:12;4529:104;-1:-1:-1;3970:706:13;;;;-1:-1:-1;3970:706:13;4667:2;4652:18;;-1:-1:-1;3970:706:13:o;5484:271::-;5667:6;5659;5654:3;5641:33;5623:3;5693:16;;5718:13;;;5693:16;5484:271;-1:-1:-1;5484:271:13:o;6235:269::-;6292:6;6345:2;6333:9;6324:7;6320:23;6316:32;6313:52;;;6361:1;6358;6351:12;6313:52;6400:9;6387:23;6450:4;6443:5;6439:16;6432:5;6429:27;6419:55;;6470:1;6467;6460:12;7277:437;7356:1;7352:12;;;;7399;;;7420:61;;7474:4;7466:6;7462:17;7452:27;;7420:61;7527:2;7519:6;7516:14;7496:18;7493:38;7490:218;;7564:77;7561:1;7554:88;7665:4;7662:1;7655:15;7693:4;7690:1;7683:15;7490:218;;7277:437;;;:::o
Swarm Source
ipfs://1a35639d29974b59856ca49be40f91fbf936ddd20662399691a28130fcf55d28
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
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.