Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Multi Chain
Multichain Addresses
0 address found via
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x60a06040 | 16492066 | 128 days 18 hrs ago | IN | Create: ExecWithSigsFacet | 0 ETH | 0.2801561 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ExecWithSigsFacet
Compiler Version
v0.8.17+commit.8df45f5f
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import {BFacetOwner} from "../facets/base/BFacetOwner.sol"; import {LibDiamond} from "../libraries/diamond/standard/LibDiamond.sol"; import {ExecWithSigsBase} from "./base/ExecWithSigsBase.sol"; import {GelatoCallUtils} from "../libraries/GelatoCallUtils.sol"; import { _getBalance, _simulateAndRevert, _revertWithFee } from "../functions/Utils.sol"; import { ExecWithSigs, ExecWithSigsFeeCollector, ExecWithSigsRelayContext, Message, MessageFeeCollector, MessageRelayContext } from "../types/CallTypes.sol"; import {_isCheckerSigner} from "./storage/SignerStorage.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { _encodeRelayContext, _encodeFeeCollector } from "@gelatonetwork/relay-context/contracts/functions/GelatoRelayUtils.sol"; contract ExecWithSigsFacet is ExecWithSigsBase, BFacetOwner { using GelatoCallUtils for address; using LibDiamond for address; //solhint-disable-next-line const-name-snakecase string public constant name = "ExecWithSigsFacet"; //solhint-disable-next-line const-name-snakecase string public constant version = "1"; address public immutable feeCollector; event LogExecWithSigs( bytes32 correlationId, Message msg, address indexed executorSigner, address indexed checkerSigner, uint256 estimatedGasUsed, address sender ); event LogExecWithSigsFeeCollector( bytes32 correlationId, MessageFeeCollector msg, address indexed executorSigner, address indexed checkerSigner, uint256 observedFee, uint256 estimatedGasUsed, address sender ); event LogExecWithSigsRelayContext( bytes32 correlationId, MessageRelayContext msg, address indexed executorSigner, address indexed checkerSigner, uint256 observedFee, uint256 estimatedGasUsed, address sender ); constructor(address _feeCollector) { feeCollector = _feeCollector; } // solhint-disable function-max-lines /// @param _call Execution payload packed into ExecWithSigs struct /// @return estimatedGasUsed Estimated gas used using gas metering function execWithSigs(ExecWithSigs calldata _call) external returns (uint256 estimatedGasUsed) { uint256 startGas = gasleft(); require( msg.sender == tx.origin, "ExecWithSigsFacet.execWithSigs: only EOAs" ); _requireSignerDeadline( _call.msg.deadline, "ExecWithSigsFacet.execWithSigs._requireSignerDeadline:" ); bytes32 digest = _getDigest(_getDomainSeparator(), _call.msg); address executorSigner = _requireExecutorSignerSignature( digest, _call.executorSignerSig, "ExecWithSigsFacet.execWithSigs._requireExecutorSignerSignature:" ); address checkerSigner = _requireCheckerSignerSignature( digest, _call.checkerSignerSig, "ExecWithSigsFacet.execWithSigs._requireCheckerSignerSignature:" ); // call forward _call.msg.service.revertingContractCall( _call.msg.data, "ExecWithSigsFacet.execWithSigs:" ); estimatedGasUsed = startGas - gasleft(); emit LogExecWithSigs( _call.correlationId, _call.msg, executorSigner, checkerSigner, estimatedGasUsed, msg.sender ); } // solhint-disable function-max-lines /// @param _call Execution payload packed into ExecWithSigsFeeCollector struct /// @return estimatedGasUsed Estimated gas used using gas metering /// @return observedFee The fee transferred to the fee collector function execWithSigsFeeCollector(ExecWithSigsFeeCollector calldata _call) external returns (uint256 estimatedGasUsed, uint256 observedFee) { uint256 startGas = gasleft(); require( msg.sender == tx.origin, "ExecWithSigsFacet.execWithSigsFeeCollector: only EOAs" ); _requireSignerDeadline( _call.msg.deadline, "ExecWithSigsFacet.execWithSigsFeeCollector._requireSignerDeadline:" ); bytes32 digest = _getDigestFeeCollector( _getDomainSeparator(), _call.msg ); address executorSigner = _requireExecutorSignerSignature( digest, _call.executorSignerSig, "ExecWithSigsFacet.execWithSigsFeeCollector._requireExecutorSignerSignature:" ); address checkerSigner = _requireCheckerSignerSignature( digest, _call.checkerSignerSig, "ExecWithSigsFacet.execWithSigsFeeCollector._requireCheckerSignerSignature:" ); { uint256 preFeeTokenBalance = _getBalance( _call.msg.feeToken, feeCollector ); // call forward + append fee collector _call.msg.service.revertingContractCall( _encodeFeeCollector(_call.msg.data, feeCollector), "ExecWithSigsFacet.execWithSigsFeeCollector:" ); uint256 postFeeTokenBalance = _getBalance( _call.msg.feeToken, feeCollector ); observedFee = postFeeTokenBalance - preFeeTokenBalance; } estimatedGasUsed = startGas - gasleft(); emit LogExecWithSigsFeeCollector( _call.correlationId, _call.msg, executorSigner, checkerSigner, observedFee, estimatedGasUsed, msg.sender ); } // solhint-disable function-max-lines /// @param _call Execution payload packed into ExecWithSigsRelayContext struct /// @return estimatedGasUsed Estimated gas used using gas metering /// @return observedFee The fee transferred to the fee collector function execWithSigsRelayContext(ExecWithSigsRelayContext calldata _call) external returns (uint256 estimatedGasUsed, uint256 observedFee) { uint256 startGas = gasleft(); require( msg.sender == tx.origin, "ExecWithSigsFacet.execWithSigsRelayContext: only EOAs" ); _requireSignerDeadline( _call.msg.deadline, "ExecWithSigsFacet.execWithSigsRelayContext._requireSignerDeadline:" ); bytes32 digest = _getDigestRelayContext( _getDomainSeparator(), _call.msg ); address executorSigner = _requireExecutorSignerSignature( digest, _call.executorSignerSig, "ExecWithSigsFacet.execWithSigsRelayContext._requireExecutorSignerSignature:" ); address checkerSigner = _requireCheckerSignerSignature( digest, _call.checkerSignerSig, "ExecWithSigsFacet.execWithSigsRelayContext._requireCheckerSignerSignature:" ); { uint256 preFeeTokenBalance = _getBalance( _call.msg.feeToken, feeCollector ); // call forward + append fee collector, feeToken, fee _call.msg.service.revertingContractCall( _encodeRelayContext( _call.msg.data, feeCollector, _call.msg.feeToken, _call.msg.fee ), "ExecWithSigsFacet.execWithSigsRelayContext:" ); uint256 postFeeTokenBalance = _getBalance( _call.msg.feeToken, feeCollector ); observedFee = postFeeTokenBalance - preFeeTokenBalance; } estimatedGasUsed = startGas - gasleft(); emit LogExecWithSigsRelayContext( _call.correlationId, _call.msg, executorSigner, checkerSigner, observedFee, estimatedGasUsed, msg.sender ); } /// @dev Used for off-chain simulation only! function simulateExecWithSigs(address _service, bytes memory _data) external { _simulateAndRevert(_service, gasleft(), _data); } /// @dev Used for off-chain simulation only! function simulateExecWithSigsFeeCollector( address _service, bytes calldata _data, address _feeToken ) external { uint256 startGas = gasleft(); uint256 preFeeTokenBalance = _getBalance(_feeToken, feeCollector); (bool success, ) = _service.call( _encodeFeeCollector(_data, feeCollector) ); uint256 postFeeTokenBalance = _getBalance(_feeToken, feeCollector); _revertWithFee( success, startGas - gasleft(), postFeeTokenBalance - preFeeTokenBalance ); } /// @dev Used for off-chain simulation only! function simulateExecWithSigsRelayContext( address _service, bytes calldata _data, address _feeToken, uint256 _fee ) external { uint256 startGas = gasleft(); uint256 preFeeTokenBalance = _getBalance(_feeToken, feeCollector); (bool success, ) = _service.call( _encodeRelayContext(_data, feeCollector, _feeToken, _fee) ); uint256 postFeeTokenBalance = _getBalance(_feeToken, feeCollector); _revertWithFee( success, startGas - gasleft(), postFeeTokenBalance - preFeeTokenBalance ); } //solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32) { return _getDomainSeparator(); } function _getDomainSeparator() internal view returns (bytes32) { return keccak256( abi.encode( keccak256( bytes( //solhint-disable-next-line max-line-length "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ) ), keccak256(bytes(name)), keccak256(bytes(version)), block.chainid, address(this) ) ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.1; // Four different types of calldata packing // 1. encodeFeeCollector: append 20 byte feeCollector address // 2. encodeRelayContext: append 20 byte feeCollector address, 20 byte feeToken address, 32 byte uint256 fee // 3. encodeFeeCollectorERC2771: append 20 byte feeCollector address, 20 byte _msgSender address // 4. encodeRelayContextERC2771: append 20 byte feeCollector address, 20 byte feeToken address, 32 byte uint256 fee, 20 byte _msgSender address function _encodeFeeCollector(bytes calldata _data, address _feeCollector) pure returns (bytes memory) { return abi.encodePacked(_data, _feeCollector); } function _encodeRelayContext( bytes calldata _data, address _feeCollector, address _feeToken, uint256 _fee ) pure returns (bytes memory) { return abi.encodePacked(_data, _feeCollector, _feeToken, _fee); } // ERC2771 Encodings // vanilla ERC2771 context encoding // solhint-disable-next-line private-vars-leading-underscore, func-visibility function _encodeERC2771Context(bytes calldata _data, address _msgSender) pure returns (bytes memory) { return abi.encodePacked(_data, _msgSender); } function _encodeFeeCollectorERC2771( bytes calldata _data, address _feeCollector, address _msgSender ) pure returns (bytes memory) { return abi.encodePacked(_data, _feeCollector, _msgSender); } function _encodeRelayContextERC2771( bytes calldata _data, address _feeCollector, address _feeToken, uint256 _fee, address _msgSender ) pure returns (bytes memory) { return abi.encodePacked(_data, _feeCollector, _feeToken, _fee, _msgSender); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_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) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @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] = _HEX_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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.3) (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 } 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"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' 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 (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // 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) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @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) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; address constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import {LibDiamond} from "../../libraries/diamond/standard/LibDiamond.sol"; abstract contract BFacetOwner { modifier onlyOwner() { LibDiamond.enforceIsContractOwner(); _; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import {GelatoString} from "../../libraries/GelatoString.sol"; import { _wasSignatureUsedAlready, _setWasSignatureUsedAlready } from "../storage/ExecWithSigsStorage.sol"; import { _isExecutorSigner, _isCheckerSigner } from "../storage/SignerStorage.sol"; import { ExecWithSigs, Message, ExecWithSigsFeeCollector, MessageFeeCollector, ExecWithSigsRelayContext, MessageRelayContext } from "../../types/CallTypes.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; abstract contract ExecWithSigsBase { using GelatoString for string; bytes32 public constant MESSAGE_TYPEHASH = keccak256( bytes( // solhint-disable-next-line max-line-length "Message(address service,bytes data,uint256 salt,uint256 deadline)" ) ); bytes32 public constant MESSAGE_FEE_COLLECTOR_TYPEHASH = keccak256( bytes( // solhint-disable-next-line max-line-length "MessageFeeCollector(address service,bytes data,uint256 salt,uint256 deadline,address feeToken)" ) ); bytes32 public constant MESSAGE_RELAY_CONTEXT_TYPEHASH = keccak256( bytes( // solhint-disable-next-line max-line-length "MessageRelayContext(address service,bytes data,uint256 salt,uint256 deadline,address feeToken,uint256 fee)" ) ); function _requireSignerDeadline( uint256 _signerDeadline, string memory _errorTrace ) internal view { require( // solhint-disable-next-line not-rely-on-time _signerDeadline == 0 || _signerDeadline >= block.timestamp, _errorTrace.suffix("deadline") ); } function _requireExecutorSignerSignature( bytes32 _digest, bytes calldata _executorSignerSig, string memory _errorTrace ) internal returns (address executorSigner) { require( !_wasSignatureUsedAlready(_executorSignerSig), _errorTrace.suffix("replay") ); ECDSA.RecoverError error; (executorSigner, error) = ECDSA.tryRecover(_digest, _executorSignerSig); require( error == ECDSA.RecoverError.NoError && _isExecutorSigner(executorSigner), _errorTrace.suffix("ECDSA.RecoverError.NoError && isExecutorSigner") ); _setWasSignatureUsedAlready(_executorSignerSig); } function _requireCheckerSignerSignature( bytes32 _digest, bytes calldata _checkerSignerSig, string memory _errorTrace ) internal returns (address checkerSigner) { require( !_wasSignatureUsedAlready(_checkerSignerSig), _errorTrace.suffix("replay") ); ECDSA.RecoverError error; (checkerSigner, error) = ECDSA.tryRecover(_digest, _checkerSignerSig); require( error == ECDSA.RecoverError.NoError && _isCheckerSigner(checkerSigner), _errorTrace.suffix("ECDSA.RecoverError.NoError && isCheckerSigner") ); _setWasSignatureUsedAlready(_checkerSignerSig); } function _getDigest(bytes32 _domainSeparator, Message calldata _msg) internal pure returns (bytes32 digest) { digest = keccak256( abi.encodePacked( "\x19\x01", _domainSeparator, keccak256(_abiEncodeExecWithSigs(_msg)) ) ); } function _getDigestFeeCollector( bytes32 _domainSeparator, MessageFeeCollector calldata _msg ) internal pure returns (bytes32 digest) { digest = keccak256( abi.encodePacked( "\x19\x01", _domainSeparator, keccak256(_abiEncodeExecWithSigsFeeCollector(_msg)) ) ); } function _getDigestRelayContext( bytes32 _domainSeparator, MessageRelayContext calldata _msg ) internal pure returns (bytes32 digest) { digest = keccak256( abi.encodePacked( "\x19\x01", _domainSeparator, keccak256(_abiEncodeExecWithSigsRelayContext(_msg)) ) ); } function _abiEncodeExecWithSigs(Message calldata _msg) internal pure returns (bytes memory) { return abi.encode( MESSAGE_TYPEHASH, _msg.service, keccak256(_msg.data), _msg.salt, _msg.deadline ); } function _abiEncodeExecWithSigsFeeCollector( MessageFeeCollector calldata _msg ) internal pure returns (bytes memory) { return abi.encode( MESSAGE_FEE_COLLECTOR_TYPEHASH, _msg.service, keccak256(_msg.data), _msg.salt, _msg.deadline, _msg.feeToken ); } function _abiEncodeExecWithSigsRelayContext( MessageRelayContext calldata _msg ) internal pure returns (bytes memory) { return abi.encode( MESSAGE_RELAY_CONTEXT_TYPEHASH, _msg.service, keccak256(_msg.data), _msg.salt, _msg.deadline, _msg.feeToken, _msg.fee ); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; struct ExecWithSigsStorage { mapping(bytes32 => bool) wasSignatureUsedAlready; } bytes32 constant _EXEC_WITH_SIGS_STORAGE = keccak256( "gelato.diamond.execWithSigs.storage" ); function _wasSignatureUsedAlready(bytes calldata _signature) view returns (bool) { return _execWithSigsStorage().wasSignatureUsedAlready[keccak256(_signature)]; } function _setWasSignatureUsedAlready(bytes calldata _signature) { _execWithSigsStorage().wasSignatureUsedAlready[ keccak256(_signature) ] = true; } //solhint-disable-next-line private-vars-leading-underscore function _execWithSigsStorage() pure returns (ExecWithSigsStorage storage ewss) { bytes32 position = _EXEC_WITH_SIGS_STORAGE; assembly { ewss.slot := position } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; using EnumerableSet for EnumerableSet.AddressSet; struct SignerStorage { EnumerableSet.AddressSet executorSigners; EnumerableSet.AddressSet checkerSigners; } bytes32 constant _SIGNER_STORAGE_POSITION = keccak256( "gelato.diamond.signer.storage" ); function _addExecutorSigner(address _executor) returns (bool) { return _signerStorage().executorSigners.add(_executor); } function _removeExecutorSigner(address _executor) returns (bool) { return _signerStorage().executorSigners.remove(_executor); } function _isExecutorSigner(address _executorSigner) view returns (bool) { return _signerStorage().executorSigners.contains(_executorSigner); } function _executorSignerAt(uint256 _index) view returns (address) { return _signerStorage().executorSigners.at(_index); } function _executorSigners() view returns (address[] memory) { return _signerStorage().executorSigners.values(); } function _numberOfExecutorSigners() view returns (uint256) { return _signerStorage().executorSigners.length(); } function _addCheckerSigner(address _checker) returns (bool) { return _signerStorage().checkerSigners.add(_checker); } function _removeCheckerSigner(address _checker) returns (bool) { return _signerStorage().checkerSigners.remove(_checker); } function _isCheckerSigner(address _checker) view returns (bool) { return _signerStorage().checkerSigners.contains(_checker); } function _checkerSignerAt(uint256 _index) view returns (address) { return _signerStorage().checkerSigners.at(_index); } function _checkerSigners() view returns (address[] memory checkers) { return _signerStorage().checkerSigners.values(); } function _numberOfCheckerSigners() view returns (uint256) { return _signerStorage().checkerSigners.length(); } function _signerStorage() pure returns (SignerStorage storage ess) { bytes32 position = _SIGNER_STORAGE_POSITION; assembly { ess.slot := position } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import {NATIVE_TOKEN} from "../constants/Tokens.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; function _getBalance(address token, address user) view returns (uint256) { if (token == address(0)) return 0; return token == NATIVE_TOKEN ? user.balance : IERC20(token).balanceOf(user); } function _simulateAndRevert( address _service, uint256 _gasleft, bytes memory _data ) { assembly { let success := call( gas(), _service, 0, add(_data, 0x20), mload(_data), 0, 0 ) mstore(0x00, success) // store success bool in first word mstore(0x20, sub(_gasleft, gas())) // store gas after success mstore(0x40, returndatasize()) // store length of return data size in third word returndatacopy(0x60, 0, returndatasize()) // store actual return data in fourth word and onwards revert(0, add(returndatasize(), 0x60)) } } function _revertWithFee( bool _success, uint256 _estimatedGasUsed, uint256 _observedFee ) pure { assembly { mstore(0x00, _success) mstore(0x20, _estimatedGasUsed) mstore(0x40, _observedFee) mstore(0x60, returndatasize()) returndatacopy(0x80, 0, returndatasize()) revert(0, add(returndatasize(), 0x80)) } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamond Standard: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ interface IDiamondCut { enum FacetCutAction { Add, Replace, Remove } // Add=0, Replace=1, Remove=2 struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; library GelatoBytes { function calldataSliceSelector(bytes calldata _bytes) internal pure returns (bytes4 selector) { selector = _bytes[0] | (bytes4(_bytes[1]) >> 8) | (bytes4(_bytes[2]) >> 16) | (bytes4(_bytes[3]) >> 24); } function memorySliceSelector(bytes memory _bytes) internal pure returns (bytes4 selector) { selector = _bytes[0] | (bytes4(_bytes[1]) >> 8) | (bytes4(_bytes[2]) >> 16) | (bytes4(_bytes[3]) >> 24); } function revertWithError(bytes memory _bytes, string memory _tracingInfo) internal pure { // 68: 32-location, 32-length, 4-ErrorSelector, UTF-8 err if (_bytes.length % 32 == 4) { bytes4 selector; assembly { selector := mload(add(0x20, _bytes)) } if (selector == 0x08c379a0) { // Function selector for Error(string) assembly { _bytes := add(_bytes, 68) } revert(string(abi.encodePacked(_tracingInfo, string(_bytes)))); } else { revert( string(abi.encodePacked(_tracingInfo, "NoErrorSelector")) ); } } else { revert( string(abi.encodePacked(_tracingInfo, "UnexpectedReturndata")) ); } } function returnError(bytes memory _bytes, string memory _tracingInfo) internal pure returns (string memory) { // 68: 32-location, 32-length, 4-ErrorSelector, UTF-8 err if (_bytes.length % 32 == 4) { bytes4 selector; assembly { selector := mload(add(0x20, _bytes)) } if (selector == 0x08c379a0) { // Function selector for Error(string) assembly { _bytes := add(_bytes, 68) } return string(abi.encodePacked(_tracingInfo, string(_bytes))); } else { return string(abi.encodePacked(_tracingInfo, "NoErrorSelector")); } } else { return string(abi.encodePacked(_tracingInfo, "UnexpectedReturndata")); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import {GelatoBytes} from "./GelatoBytes.sol"; library GelatoCallUtils { using GelatoBytes for bytes; function revertingContractCall( address _contract, bytes memory _data, string memory _errorMsg ) internal returns (bytes memory returndata) { bool success; (success, returndata) = _contract.call(_data); // solhint-disable-next-line max-line-length // https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f9b6fc3fdab7aca33a9cfa8837c5cd7f67e176be/contracts/utils/AddressUpgradeable.sol#L177 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(_contract), string(abi.encodePacked(_errorMsg, "Call to non contract")) ); } } else { returndata.revertWithError(_errorMsg); } } // solhint-disable-next-line max-line-length // https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f9b6fc3fdab7aca33a9cfa8837c5cd7f67e176be/contracts/utils/AddressUpgradeable.sol#L36 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; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; library GelatoString { function startsWithOK(string memory _str) internal pure returns (bool) { if ( bytes(_str).length >= 2 && bytes(_str)[0] == "O" && bytes(_str)[1] == "K" ) return true; return false; } function revertWithInfo(string memory _error, string memory _tracingInfo) internal pure { revert(string(abi.encodePacked(_tracingInfo, _error))); } function prefix(string memory _second, string memory _first) internal pure returns (string memory) { return string(abi.encodePacked(_first, _second)); } function suffix(string memory _first, string memory _second) internal pure returns (string memory) { return string(abi.encodePacked(_first, _second)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; // solhint-disable max-line-length // https://github.com/mudgen/diamond-3/blob/b009cd08b7822bad727bbcc47aa1b50d8b50f7f0/contracts/libraries/LibDiamond.sol#L1 /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamond Standard: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ import "../../../interfaces/diamond/standard/IDiamondCut.sol"; // Custom due to incorrect string casting (non UTF-8 formatted) import {GelatoBytes} from "../../../libraries/GelatoBytes.sol"; library LibDiamond { bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); struct FacetAddressAndPosition { address facetAddress; uint16 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array } struct FacetFunctionSelectors { bytes4[] functionSelectors; uint16 facetAddressPosition; // position of facetAddress in facetAddresses array } struct DiamondStorage { // maps function selector to the facet address and // the position of the selector in the facetFunctionSelectors.selectors array mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition; // maps facet addresses to function selectors mapping(address => FacetFunctionSelectors) facetFunctionSelectors; // facet addresses address[] facetAddresses; // Used to query if a contract implements an interface. // Used to implement ERC-165. mapping(bytes4 => bool) supportedInterfaces; // owner of the contract address contractOwner; } function diamondStorage() internal pure returns (DiamondStorage storage ds) { bytes32 position = DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } } event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); function setContractOwner(address _newOwner) internal { DiamondStorage storage ds = diamondStorage(); address previousOwner = ds.contractOwner; ds.contractOwner = _newOwner; emit OwnershipTransferred(previousOwner, _newOwner); } function contractOwner() internal view returns (address contractOwner_) { contractOwner_ = diamondStorage().contractOwner; } function isContractOwner(address _guy) internal view returns (bool) { return _guy == contractOwner(); } function enforceIsContractOwner() internal view { require( msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner" ); } event DiamondCut( IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata ); // Internal function version of diamondCut function diamondCut( IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata ) internal { for ( uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++ ) { IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action; if (action == IDiamondCut.FacetCutAction.Add) { addFunctions( _diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors ); } else if (action == IDiamondCut.FacetCutAction.Replace) { replaceFunctions( _diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors ); } else if (action == IDiamondCut.FacetCutAction.Remove) { removeFunctions( _diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors ); } else { revert("LibDiamondCut: Incorrect FacetCutAction"); } } emit DiamondCut(_diamondCut, _init, _calldata); initializeDiamondCut(_init, _calldata); } function addFunctions( address _facetAddress, bytes4[] memory _functionSelectors ) internal { require( _functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut" ); DiamondStorage storage ds = diamondStorage(); // uint16 selectorCount = uint16(diamondStorage().selectors.length); require( _facetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)" ); uint16 selectorPosition = uint16( ds.facetFunctionSelectors[_facetAddress].functionSelectors.length ); // add new facet address if it does not exist if (selectorPosition == 0) { enforceHasContractCode( _facetAddress, "LibDiamondCut: New facet has no code" ); ds .facetFunctionSelectors[_facetAddress] .facetAddressPosition = uint16(ds.facetAddresses.length); ds.facetAddresses.push(_facetAddress); } for ( uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++ ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds .selectorToFacetAndPosition[selector] .facetAddress; require( oldFacetAddress == address(0), "LibDiamondCut: Can't add function that already exists" ); ds.facetFunctionSelectors[_facetAddress].functionSelectors.push( selector ); ds .selectorToFacetAndPosition[selector] .facetAddress = _facetAddress; ds .selectorToFacetAndPosition[selector] .functionSelectorPosition = selectorPosition; selectorPosition++; } } function replaceFunctions( address _facetAddress, bytes4[] memory _functionSelectors ) internal { require( _functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut" ); DiamondStorage storage ds = diamondStorage(); require( _facetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)" ); uint16 selectorPosition = uint16( ds.facetFunctionSelectors[_facetAddress].functionSelectors.length ); // add new facet address if it does not exist if (selectorPosition == 0) { enforceHasContractCode( _facetAddress, "LibDiamondCut: New facet has no code" ); ds .facetFunctionSelectors[_facetAddress] .facetAddressPosition = uint16(ds.facetAddresses.length); ds.facetAddresses.push(_facetAddress); } for ( uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++ ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds .selectorToFacetAndPosition[selector] .facetAddress; require( oldFacetAddress != _facetAddress, "LibDiamondCut: Can't replace function with same function" ); removeFunction(oldFacetAddress, selector); // add function ds .selectorToFacetAndPosition[selector] .functionSelectorPosition = selectorPosition; ds.facetFunctionSelectors[_facetAddress].functionSelectors.push( selector ); ds .selectorToFacetAndPosition[selector] .facetAddress = _facetAddress; selectorPosition++; } } function removeFunctions( address _facetAddress, bytes4[] memory _functionSelectors ) internal { require( _functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut" ); DiamondStorage storage ds = diamondStorage(); // if function does not exist then do nothing and return require( _facetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)" ); for ( uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++ ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds .selectorToFacetAndPosition[selector] .facetAddress; removeFunction(oldFacetAddress, selector); } } function removeFunction(address _facetAddress, bytes4 _selector) internal { DiamondStorage storage ds = diamondStorage(); require( _facetAddress != address(0), "LibDiamondCut: Can't remove function that doesn't exist" ); // an immutable function is a function defined directly in a diamond require( _facetAddress != address(this), "LibDiamondCut: Can't remove immutable function" ); // replace selector with last selector, then delete last selector uint256 selectorPosition = ds .selectorToFacetAndPosition[_selector] .functionSelectorPosition; uint256 lastSelectorPosition = ds .facetFunctionSelectors[_facetAddress] .functionSelectors .length - 1; // if not the same then replace _selector with lastSelector if (selectorPosition != lastSelectorPosition) { bytes4 lastSelector = ds .facetFunctionSelectors[_facetAddress] .functionSelectors[lastSelectorPosition]; ds.facetFunctionSelectors[_facetAddress].functionSelectors[ selectorPosition ] = lastSelector; ds .selectorToFacetAndPosition[lastSelector] .functionSelectorPosition = uint16(selectorPosition); } // delete the last selector ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop(); delete ds.selectorToFacetAndPosition[_selector]; // if no more selectors for facet address then delete the facet address if (lastSelectorPosition == 0) { // replace facet address with last facet address and delete last facet address uint256 lastFacetAddressPosition = ds.facetAddresses.length - 1; uint256 facetAddressPosition = ds .facetFunctionSelectors[_facetAddress] .facetAddressPosition; if (facetAddressPosition != lastFacetAddressPosition) { address lastFacetAddress = ds.facetAddresses[ lastFacetAddressPosition ]; ds.facetAddresses[facetAddressPosition] = lastFacetAddress; ds .facetFunctionSelectors[lastFacetAddress] .facetAddressPosition = uint16(facetAddressPosition); } ds.facetAddresses.pop(); delete ds .facetFunctionSelectors[_facetAddress] .facetAddressPosition; } } function initializeDiamondCut(address _init, bytes memory _calldata) internal { if (_init == address(0)) { require( _calldata.length == 0, "LibDiamondCut: _init is address(0) but_calldata is not empty" ); } else { require( _calldata.length > 0, "LibDiamondCut: _calldata is empty but _init is not address(0)" ); if (_init != address(this)) { enforceHasContractCode( _init, "LibDiamondCut: _init address has no code" ); } (bool success, bytes memory error) = _init.delegatecall(_calldata); if (!success) { if (error.length > 0) { // bubble up the error GelatoBytes.revertWithError(error, "LibDiamondCut:_init:"); } else { revert("LibDiamondCut: _init function reverted"); } } } } function enforceHasContractCode( address _contract, string memory _errorMessage ) internal view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } require(contractSize > 0, _errorMessage); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; struct Message { address service; bytes data; uint256 salt; uint256 deadline; } struct MessageFeeCollector { address service; bytes data; uint256 salt; uint256 deadline; address feeToken; } struct MessageRelayContext { address service; bytes data; uint256 salt; uint256 deadline; address feeToken; uint256 fee; } struct ExecWithSigs { bytes32 correlationId; Message msg; bytes executorSignerSig; bytes checkerSignerSig; } struct ExecWithSigsFeeCollector { bytes32 correlationId; MessageFeeCollector msg; bytes executorSignerSig; bytes checkerSignerSig; } struct ExecWithSigsRelayContext { bytes32 correlationId; MessageRelayContext msg; bytes executorSignerSig; bytes checkerSignerSig; }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_feeCollector","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"indexed":false,"internalType":"struct Message","name":"msg","type":"tuple"},{"indexed":true,"internalType":"address","name":"executorSigner","type":"address"},{"indexed":true,"internalType":"address","name":"checkerSigner","type":"address"},{"indexed":false,"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"LogExecWithSigs","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"}],"indexed":false,"internalType":"struct MessageFeeCollector","name":"msg","type":"tuple"},{"indexed":true,"internalType":"address","name":"executorSigner","type":"address"},{"indexed":true,"internalType":"address","name":"checkerSigner","type":"address"},{"indexed":false,"internalType":"uint256","name":"observedFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"LogExecWithSigsFeeCollector","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"indexed":false,"internalType":"struct MessageRelayContext","name":"msg","type":"tuple"},{"indexed":true,"internalType":"address","name":"executorSigner","type":"address"},{"indexed":true,"internalType":"address","name":"checkerSigner","type":"address"},{"indexed":false,"internalType":"uint256","name":"observedFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"LogExecWithSigsRelayContext","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MESSAGE_FEE_COLLECTOR_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MESSAGE_RELAY_CONTEXT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MESSAGE_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct Message","name":"msg","type":"tuple"},{"internalType":"bytes","name":"executorSignerSig","type":"bytes"},{"internalType":"bytes","name":"checkerSignerSig","type":"bytes"}],"internalType":"struct ExecWithSigs","name":"_call","type":"tuple"}],"name":"execWithSigs","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"}],"internalType":"struct MessageFeeCollector","name":"msg","type":"tuple"},{"internalType":"bytes","name":"executorSignerSig","type":"bytes"},{"internalType":"bytes","name":"checkerSignerSig","type":"bytes"}],"internalType":"struct ExecWithSigsFeeCollector","name":"_call","type":"tuple"}],"name":"execWithSigsFeeCollector","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"internalType":"uint256","name":"observedFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"internalType":"struct MessageRelayContext","name":"msg","type":"tuple"},{"internalType":"bytes","name":"executorSignerSig","type":"bytes"},{"internalType":"bytes","name":"checkerSignerSig","type":"bytes"}],"internalType":"struct ExecWithSigsRelayContext","name":"_call","type":"tuple"}],"name":"execWithSigsRelayContext","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"internalType":"uint256","name":"observedFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_service","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"simulateExecWithSigs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_service","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"address","name":"_feeToken","type":"address"}],"name":"simulateExecWithSigsFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_service","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"address","name":"_feeToken","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"simulateExecWithSigsRelayContext","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a060405234801561001057600080fd5b5060405161240638038061240683398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b60805161233c6100ca600039600081816101d001528181610388015281816103d1015281816104d90152818161051201528181610593015281816109f501528181610afd01528181610b360152610bb5015261233c6000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063544dd3951161008c57806383ec30771161006657806383ec3077146101c3578063c415b95c146101cb578063cd2cf3661461020a578063f111786a1461021d57600080fd5b8063544dd3951461018857806354fd4d501461019057806367c62fe0146101b057600080fd5b806306fdde03146100d45780630a4806ce1461011a5780631c367bc3146101425780633644e515146101575780634522589f1461016d57806346e356b114610180575b600080fd5b61010460405180604001604052806011815260200170115e1958d5da5d1a14da59dcd19858d95d607a1b81525081565b6040516101119190611775565b60405180910390f35b61012d6101283660046117c0565b610230565b60408051928352602083019190915201610111565b61015561015036600461185b565b6104cc565b005b61015f6105e2565b604051908152602001610111565b61015f61017b3660046117c0565b6105f1565b61015f610818565b61015f61083b565b610104604051806040016040528060018152602001603160f81b81525081565b6101556101be3660046118de565b61085e565b61015f61086d565b6101f27f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610111565b61012d6102183660046117c0565b610890565b61015561022b3660046119a0565b610af0565b60008060005a90503332146102aa5760405162461bcd60e51b815260206004820152603560248201527f45786563576974685369677346616365742e657865635769746853696773466560448201527465436f6c6c6563746f723a206f6e6c7920454f417360581b60648201526084015b60405180910390fd5b6102dc6102ba6020860186611a05565b606001356040518060800160405280604281526020016121f160429139610bf4565b60006102fb6102e9610c4e565b6102f66020880188611a05565b610d29565b9050600061032e826103106040890189611a25565b6040518060800160405280604b8152602001611ffd604b9139610d7f565b905060006103618361034360608a018a611a25565b6040518060800160405280604a81526020016120bf604a9139610e9d565b905060006103ac61037560208a018a611a05565b6103869060a0810190608001611a6c565b7f0000000000000000000000000000000000000000000000000000000000000000610f89565b90506104396103f56103c160208b018b611a05565b6103cf906020810190611a25565b7f0000000000000000000000000000000000000000000000000000000000000000611049565b6040518060600160405280602b815260200161229d602b913961041b60208c018c611a05565b610429906020810190611a6c565b6001600160a01b03169190611078565b50600061044c61037560208b018b611a05565b90506104588282611a87565b965050505a6104679085611a87565b95506001600160a01b038082169083167febee01ccf79a62d5083b2b10c32a7991d2c2acfc80c6d73c0380901c888ccbc189356104a760208c018c611a05565b898b336040516104bb959493929190611b17565b60405180910390a350505050915091565b60005a905060006104fd847f0000000000000000000000000000000000000000000000000000000000000000610f89565b90506000876001600160a01b031661053888887f0000000000000000000000000000000000000000000000000000000000000000898961114e565b6040516105459190611ba9565b6000604051808303816000865af19150503d8060008114610582576040519150601f19603f3d011682016040523d82523d6000602084013e610587565b606091505b5050905060006105b7867f0000000000000000000000000000000000000000000000000000000000000000610f89565b90506105d7825a6105c89087611a87565b6105d28685611a87565b611183565b505050505050505050565b60006105ec610c4e565b905090565b6000805a90503332146106585760405162461bcd60e51b815260206004820152602960248201527f45786563576974685369677346616365742e6578656357697468536967733a206044820152686f6e6c7920454f417360b81b60648201526084016102a1565b61068a6106686020850185611bbb565b6060013560405180606001604052806036815260200161204860369139610bf4565b60006106a9610697610c4e565b6106a46020870187611bbb565b6111a1565b905060006106dc826106be6040880188611a25565b6040518060600160405280603f81526020016122c8603f9139610d7f565b9050600061070f836106f16060890189611a25565b6040518060600160405280603e8152602001612186603e9139610e9d565b90506107a96107216020880188611bbb565b61072f906020810190611a25565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505060408051808201909152601f81527f45786563576974685369677346616365742e6578656357697468536967733a0060208083019190915290925061041b91508a018a611bbb565b505a6107b59085611a87565b94506001600160a01b038082169083167f7bfffe4b1a7ee0d5ebb45f7d8b0eea0a4ddfa94221b2325b850e5a5925e5e97088356107f560208b018b611bbb565b89336040516108079493929190611bd1565b60405180910390a350505050919050565b60405180608001604052806041815260200161207e604191398051906020012081565b6040518060a00160405280606a8152602001612233606a91398051906020012081565b610869825a836111ad565b5050565b6040518060800160405280605e8152602001611ee4605e91398051906020012081565b60008060005a90503332146109055760405162461bcd60e51b815260206004820152603560248201527f45786563576974685369677346616365742e65786563576974685369677352656044820152746c6179436f6e746578743a206f6e6c7920454f417360581b60648201526084016102a1565b6109376109156020860186611c46565b60600135604051806080016040528060428152602001611fbb60429139610bf4565b6000610956610944610c4e565b6109516020880188611c46565b6111d6565b905060006109898261096b6040890189611a25565b6040518060800160405280604b8152602001611f70604b9139610d7f565b905060006109bc8361099e60608a018a611a25565b6040518060800160405280604a8152602001611e9a604a9139610e9d565b905060006109d061037560208a018a611c46565b9050610a6e610a486109e560208b018b611c46565b6109f3906020810190611a25565b7f0000000000000000000000000000000000000000000000000000000000000000610a2160208e018e611c46565b610a329060a0810190608001611a6c565b610a3f60208f018f611c46565b60a0013561114e565b6040518060600160405280602b815260200161215b602b913961041b60208c018c611c46565b506000610a8161037560208b018b611c46565b9050610a8d8282611a87565b965050505a610a9c9085611a87565b95506001600160a01b038082169083167fa5c57cb93d2124da6530c224fa6138483ff7ecd2959d2dad024a9d050076cc1a8935610adc60208c018c611c46565b898b336040516104bb959493929190611c5c565b60005a90506000610b21837f0000000000000000000000000000000000000000000000000000000000000000610f89565b90506000866001600160a01b0316610b5a87877f0000000000000000000000000000000000000000000000000000000000000000611049565b604051610b679190611ba9565b6000604051808303816000865af19150503d8060008114610ba4576040519150601f19603f3d011682016040523d82523d6000602084013e610ba9565b606091505b505090506000610bd9857f0000000000000000000000000000000000000000000000000000000000000000610f89565b9050610bea825a6105c89087611a87565b5050505050505050565b811580610c015750428210155b604080518082019091526008815267646561646c696e6560c01b6020820152610c2b9083906111e2565b90610c495760405162461bcd60e51b81526004016102a19190611775565b505050565b60006040518060800160405280605281526020016121096052913980516020918201206040805180820182526011815270115e1958d5da5d1a14da59dcd19858d95d607a1b908401528051808201825260018152603160f81b908401528051928301919091527f176566dd3634ff88354f49a20832f5507a82745dc224d42b5843c5e757ade4b5908201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b600082610d358361120e565b8051602091820120604051610d6193920161190160f01b81526002810192909252602282015260420190565b60405160208183030381529060405280519060200120905092915050565b6000610d8b84846112ce565b15610dbd604051806040016040528060068152602001657265706c617960d01b815250846111e290919063ffffffff16565b90610ddb5760405162461bcd60e51b81526004016102a19190611775565b506000610e1e8686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061132892505050565b90925090506000816004811115610e3757610e37611d09565b148015610e485750610e488261136d565b610e6b6040518060600160405280602e8152602001611f42602e913985906111e2565b90610e895760405162461bcd60e51b81526004016102a19190611775565b50610e9485856113b7565b50949350505050565b6000610ea984846112ce565b15610edb604051806040016040528060068152602001657265706c617960d01b815250846111e290919063ffffffff16565b90610ef95760405162461bcd60e51b81526004016102a19190611775565b506000610f3c8686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061132892505050565b90925090506000816004811115610f5557610f55611d09565b148015610f665750610f668261141e565b610e6b6040518060600160405280602d81526020016121c4602d913985906111e2565b60006001600160a01b038316610fa157506000611043565b6001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14611034576040516370a0823160e01b81526001600160a01b0383811660048301528416906370a0823190602401602060405180830381865afa15801561100b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102f9190611d1f565b611040565b816001600160a01b0316315b90505b92915050565b606083838360405160200161106093929190611d38565b60405160208183030381529060405290509392505050565b60606000846001600160a01b0316846040516110949190611ba9565b6000604051808303816000865af19150503d80600081146110d1576040519150601f19603f3d011682016040523d82523d6000602084013e6110d6565b606091505b5092509050801561113c578151600003611137576001600160a01b0385163b1515836040516020016111089190611d5e565b604051602081830303815290604052906111355760405162461bcd60e51b81526004016102a19190611775565b505b611146565b6111468284611487565b509392505050565b60608585858585604051602001611169959493929190611d96565b604051602081830303815290604052905095945050505050565b8260005281602052806040523d6060523d600060803e60803d016000fd5b600082610d3583611519565b6000808251602084016000875af16000525a82036020523d6040523d600060603e60603d016000fd5b600082610d35836115a8565b606082826040516020016111f7929190611dcd565b604051602081830303815290604052905092915050565b60606040518060800160405280605e8152602001611ee4605e913980516020918201209061123e90840184611a6c565b61124b6020850185611a25565b604051611259929190611dfc565b60405180910390208460400135856060013586608001602081019061127e9190611a6c565b6040805160208101979097526001600160a01b03958616908701526060860193909352608085019190915260a08401521660c082015260e0015b6040516020818303038152906040529050919050565b60007f90f0bdc952e556bcffe177d42d0a1e2c48fc4212efc230d6acee71a6d61164446040516000906113049086908690611dfc565b604080519182900390912082526020820192909252016000205460ff169392505050565b600080825160410361135e5760208301516040840151606085015160001a61135287828585611664565b94509450505050611366565b506000905060025b9250929050565b6000611043827fdee078fadc21593590e9046d81e4518a7b3feb16bdee74b2d2488cd4455264d0906001600160a01b03811660009081526001830160205260408120541515611040565b60017f90f0bdc952e556bcffe177d42d0a1e2c48fc4212efc230d6acee71a6d61164446040516000906113ed9086908690611dfc565b6040518091039020815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6001600160a01b03811660009081527fdee078fadc21593590e9046d81e4518a7b3feb16bdee74b2d2488cd4455264d36020526040812054611043907fdee078fadc21593590e9046d81e4518a7b3feb16bdee74b2d2488cd4455264d290849084901515611040565b602082516114959190611e0c565b6004036115085760208201516001600160e01b0319811662461bcd60e51b036114f75760448301925081836040516020016114d1929190611dcd565b60408051601f198184030181529082905262461bcd60e51b82526102a191600401611775565b816040516020016114d19190611e2e565b806040516020016114d19190611e61565b606060405180608001604052806041815260200161207e6041913980516020918201209061154990840184611a6c565b6115566020850185611a25565b604051611564929190611dfc565b6040805191829003822060208301949094526001600160a01b03909216818301526060808201939093529084013560808201529083013560a082015260c0016112b8565b60606040518060a00160405280606a8152602001612233606a91398051602091820120906115d890840184611a6c565b6115e56020850185611a25565b6040516115f3929190611dfc565b6040518091039020846040013585606001358660800160208101906116189190611a6c565b6040805160208101979097526001600160a01b03958616908701526060860193909352608085019190915260a084810191909152911660c083015283013560e0820152610100016112b8565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561169b5750600090506003611748565b8460ff16601b141580156116b357508460ff16601c14155b156116c45750600090506004611748565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611718573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661174157600060019250925050611748565b9150600090505b94509492505050565b60005b8381101561176c578181015183820152602001611754565b50506000910152565b6020815260008251806020840152611794816040850160208701611751565b601f01601f19169190910160400192915050565b6000608082840312156117ba57600080fd5b50919050565b6000602082840312156117d257600080fd5b813567ffffffffffffffff8111156117e957600080fd5b6117f5848285016117a8565b949350505050565b80356001600160a01b038116811461181457600080fd5b919050565b60008083601f84011261182b57600080fd5b50813567ffffffffffffffff81111561184357600080fd5b60208301915083602082850101111561136657600080fd5b60008060008060006080868803121561187357600080fd5b61187c866117fd565b9450602086013567ffffffffffffffff81111561189857600080fd5b6118a488828901611819565b90955093506118b79050604087016117fd565b949793965091946060013592915050565b634e487b7160e01b600052604160045260246000fd5b600080604083850312156118f157600080fd5b6118fa836117fd565b9150602083013567ffffffffffffffff8082111561191757600080fd5b818501915085601f83011261192b57600080fd5b81358181111561193d5761193d6118c8565b604051601f8201601f19908116603f01168101908382118183101715611965576119656118c8565b8160405282815288602084870101111561197e57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b600080600080606085870312156119b657600080fd5b6119bf856117fd565b9350602085013567ffffffffffffffff8111156119db57600080fd5b6119e787828801611819565b90945092506119fa9050604086016117fd565b905092959194509250565b60008235609e19833603018112611a1b57600080fd5b9190910192915050565b6000808335601e19843603018112611a3c57600080fd5b83018035915067ffffffffffffffff821115611a5757600080fd5b60200191503681900382131561136657600080fd5b600060208284031215611a7e57600080fd5b611040826117fd565b8181038181111561104357634e487b7160e01b600052601160045260246000fd5b6000808335601e19843603018112611abf57600080fd5b830160208101925035905067ffffffffffffffff811115611adf57600080fd5b80360382131561136657600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b85815260a0602082015260006001600160a01b0380611b35886117fd565b1660a0840152611b486020880188611aa8565b60a060c0860152611b5e61014086018284611aee565b915050604088013560e0850152606088013561010085015281611b8360808a016117fd565b166101208501526040840196909652606083019490945250911660809091015292915050565b60008251611a1b818460208701611751565b60008235607e19833603018112611a1b57600080fd5b8481526080602082015260006001600160a01b0380611bef876117fd565b166080840152611c026020870187611aa8565b608060a0860152611c1861010086018284611aee565b60408981013560c08801526060998a013560e088015286019790975250509290921693019290925292915050565b6000823560be19833603018112611a1b57600080fd5b85815260a0602082015260006001600160a01b0380611c7a886117fd565b1660a0840152611c8d6020880188611aa8565b60c080860152611ca261016086018284611aee565b915050604088013560e0850152606088013561010085015281611cc760808a016117fd565b1661012085015260a08801356101408501528092505050846040830152836060830152611cff60808301846001600160a01b03169052565b9695505050505050565b634e487b7160e01b600052602160045260246000fd5b600060208284031215611d3157600080fd5b5051919050565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b60008251611d70818460208701611751565b7310d85b1b081d1bc81b9bdb8818dbdb9d1c9858dd60621b920191825250601401919050565b848682376bffffffffffffffffffffffff19606094851b8116959091019485529190921b1660148301526028820152604801919050565b60008351611ddf818460208801611751565b835190830190611df3818360208801611751565b01949350505050565b8183823760009101908152919050565b600082611e2957634e487b7160e01b600052601260045260246000fd5b500690565b60008251611e40818460208701611751565b6e2737a2b93937b929b2b632b1ba37b960891b920191825250600f01919050565b60008251611e73818460208701611751565b73556e657870656374656452657475726e6461746160601b92019182525060140191905056fe45786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578742e5f72657175697265436865636b65725369676e65725369676e61747572653a4d657373616765466565436f6c6c6563746f72286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652c6164647265737320666565546f6b656e2945434453412e5265636f7665724572726f722e4e6f4572726f722026262069734578656375746f725369676e657245786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578742e5f726571756972654578656375746f725369676e65725369676e61747572653a45786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578742e5f726571756972655369676e6572446561646c696e653a45786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f722e5f726571756972654578656375746f725369676e65725369676e61747572653a45786563576974685369677346616365742e6578656357697468536967732e5f726571756972655369676e6572446561646c696e653a4d657373616765286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652945786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f722e5f72657175697265436865636b65725369676e65725369676e61747572653a454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e74726163742945786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578743a45786563576974685369677346616365742e6578656357697468536967732e5f72657175697265436865636b65725369676e65725369676e61747572653a45434453412e5265636f7665724572726f722e4e6f4572726f72202626206973436865636b65725369676e657245786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f722e5f726571756972655369676e6572446561646c696e653a4d65737361676552656c6179436f6e74657874286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652c6164647265737320666565546f6b656e2c75696e74323536206665652945786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f723a45786563576974685369677346616365742e6578656357697468536967732e5f726571756972654578656375746f725369676e65725369676e61747572653aa264697066735822122098df76f8a5d8400adb4276e037edb6e2785204610aa3450147c992244408337864736f6c634300081100330000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf
-----Decoded View---------------
Arg [0] : _feeCollector (address): 0x3AC05161b76a35c1c28dC99Aa01BEd7B24cEA3bf
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf
Loading...
Loading
Loading...
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.
[ 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.