{"constructor_args":null,"is_partially_verified":true,"is_changed_bytecode":false,"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"payable","type":"fallback"}],"conflicting_implementations":null,"certified":false,"additional_sources":[],"is_verified_via_sourcify":true,"can_be_visualized_via_sol2uml":true,"evm_version":"paris","language":"solidity","is_verified_via_eth_bytecode_db":true,"is_fully_verified":false,"license_type":"none","is_blueprint":false,"name":"Avocado","creation_bytecode":"0x60a060405234801561001057600080fd5b5060408051808201825260048152638c65738960e01b60208201529051600091339161003c91906100b2565b600060405180830381855afa9150503d8060008114610077576040519150601f19603f3d011682016040523d82523d6000602084013e61007c565b606091505b506020810151604090910151608052600080546001600160a01b0319166001600160a01b03909216919091179055506100e19050565b6000825160005b818110156100d357602081860181015185830152016100b9565b506000920191825250919050565b6080516101476100fb6000396000600601526101476000f3fe60806040527f00000000000000000000000000000000000000000000000000000000000000006000357f4d42058500000000000000000000000000000000000000000000000000000000810161006f5773ffffffffffffffffffffffffffffffffffffffff821660005260206000f35b7f68beab3f0000000000000000000000000000000000000000000000000000000081036100a0578160005260206000f35b73ffffffffffffffffffffffffffffffffffffffff600054167f874095c60000000000000000000000000000000000000000000000000000000082036100ea578060005260206000f35b3660008037600080366000845af49150503d6000803e80801561010c573d6000f35b3d6000fdfea2646970667358221220bf171834b0948ebffd196d6a4208dbd5d0a71f76dfac9d90499de318c59558fc64736f6c63430008120033","external_libraries":[],"proxy_type":null,"implementations":[],"verified_at":"2024-03-03T22:10:40.510610Z","is_verified_via_verifier_alliance":false,"compiler_version":"0.8.18+commit.87f61d96","decoded_constructor_args":null,"sourcify_repo_url":"https://repo.sourcify.dev/1/0x4F6F977aCDD1177DCD81aB83074855EcB9C2D49e","optimization_runs":10000000,"compiler_settings":{"evmVersion":"paris","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":true,"runs":10000000},"remappings":[]},"is_verified":true,"verified_twin_address_hash":null,"optimization_enabled":true,"deployed_bytecode":"0x60806040527f000000000000000000000001c7810aa3b0c6a2778eecc114b93d59b2e9da9e056000357f4d42058500000000000000000000000000000000000000000000000000000000810161006f5773ffffffffffffffffffffffffffffffffffffffff821660005260206000f35b7f68beab3f0000000000000000000000000000000000000000000000000000000081036100a0578160005260206000f35b73ffffffffffffffffffffffffffffffffffffffff600054167f874095c60000000000000000000000000000000000000000000000000000000082036100ea578060005260206000f35b3660008037600080366000845af49150503d6000803e80801561010c573d6000f35b3d6000fdfea2646970667358221220bf171834b0948ebffd196d6a4208dbd5d0a71f76dfac9d90499de318c59558fc64736f6c63430008120033","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.18;\n\n/// @title   IAvocado\n/// @notice  interface to access internal vars on-chain\ninterface IAvocado {\n    function _avoImpl() external view returns (address);\n\n    function _data() external view returns (uint256);\n\n    function _owner() external view returns (address);\n}\n\n/// @title      Avocado\n/// @notice     Proxy for Avocados as deployed by the AvoFactory.\n///             Basic Proxy with fallback to delegate and address for implementation contract at storage 0x0\n//\n// @dev        If this contract changes then the deployment addresses for new Avocados through factory change too!!\n//             Relayers might want to pass in version as new param then to forward to the correct factory\ncontract Avocado {\n    /// @notice flexible immutable data slot.\n    /// first 20 bytes: address owner\n    /// next 4 bytes: uint32 index\n    /// next 1 byte: uint8 type\n    /// next 9 bytes: used flexible for use-cases found in the future\n    uint256 internal immutable _data;\n\n    /// @notice address of the Avocado logic / implementation contract. IMPORTANT: SAME STORAGE SLOT AS FOR PROXY\n    //\n    // @dev    _avoImpl MUST ALWAYS be the first declared variable here in the proxy and in the logic contract\n    //         when upgrading, the storage at memory address 0x0 is upgraded (first slot).\n    //         To reduce deployment costs this variable is internal but can still be retrieved with\n    //         _avoImpl(), see code and comments in fallback below\n    address internal _avoImpl;\n\n    /// @notice   sets _avoImpl & immutable _data, fetching it from msg.sender.\n    //\n    // @dev      those values are not input params to not influence the deterministic Create2 address!\n    constructor() {\n        // \"\\x8c\\x65\\x73\\x89\" is hardcoded bytes of function selector for transientDeployData()\n        (, bytes memory deployData_) = msg.sender.staticcall(bytes(\"\\x8c\\x65\\x73\\x89\"));\n\n        address impl_;\n        uint256 data_;\n        assembly {\n            // cast first 20 bytes to version address (_avoImpl)\n            impl_ := mload(add(deployData_, 0x20))\n\n            // cast bytes in position 0x40 to uint256 data; deployData_ plus 0x40 due to padding\n            data_ := mload(add(deployData_, 0x40))\n        }\n\n        _data = data_;\n        _avoImpl = impl_;\n    }\n\n    /// @notice Delegates the current call to `_avoImpl` unless one of the view methods is called:\n    ///         `_avoImpl()` returns the address for `_avoImpl`, `_owner()` returns the first\n    ///         20 bytes of `_data`, `_data()` returns `_data`.\n    //\n    // @dev    Mostly based on OpenZeppelin Proxy.sol\n    // logic contract must not implement a function `_avoImpl()`, `_owner()` or  `_data()`\n    // as they will not be callable due to collision\n    fallback() external payable {\n        uint256 data_ = _data;\n        assembly {\n            let functionSelector_ := calldataload(0)\n\n            // 0xb2bdfa7b = function selector for _owner()\n            if eq(functionSelector_, 0xb2bdfa7b00000000000000000000000000000000000000000000000000000000) {\n                // store address owner at memory address 0x0, loading only last 20 bytes through the & mask\n                mstore(0, and(data_, 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff))\n                return(0, 0x20) // send 32 bytes of memory slot 0 as return value\n            }\n\n            // 0x68beab3f = function selector for _data()\n            if eq(functionSelector_, 0x68beab3f00000000000000000000000000000000000000000000000000000000) {\n                mstore(0, data_) // store uint256 _data at memory address 0x0\n                return(0, 0x20) // send 32 bytes of memory slot 0 as return value\n            }\n\n            // load address avoImpl_ from storage\n            let avoImpl_ := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)\n\n            // first 4 bytes of calldata specify which function to call.\n            // if those first 4 bytes == 874095c6 (function selector for _avoImpl()) then we return the _avoImpl address\n            // The value is right padded to 32-bytes with 0s\n            if eq(functionSelector_, 0x874095c600000000000000000000000000000000000000000000000000000000) {\n                mstore(0, avoImpl_) // store address avoImpl_ at memory address 0x0\n                return(0, 0x20) // send 32 bytes of memory slot 0 as return value\n            }\n\n            // @dev code below is taken from OpenZeppelin Proxy.sol _delegate function\n\n            // Copy msg.data. We take full control of memory in this inline assembly\n            // block because it will not return to Solidity code. We overwrite the\n            // Solidity scratch pad at memory position 0.\n            calldatacopy(0, 0, calldatasize())\n\n            // Call the implementation.\n            // out and outsize are 0 because we don't know the size yet.\n            let result := delegatecall(gas(), avoImpl_, 0, calldatasize(), 0, 0)\n\n            // Copy the returned data.\n            returndatacopy(0, 0, returndatasize())\n\n            switch result\n            // delegatecall returns 0 on error.\n            case 0 {\n                revert(0, returndatasize())\n            }\n            default {\n                return(0, returndatasize())\n            }\n        }\n    }\n}\n","creation_status":"success","file_path":"contracts/Avocado.sol"}