Contract Address Details

0xd9cB76bcAE7219Fb3cB1936401804D7c9F921bCD

Contract Name
ProxyFactory
Creator
0x4e59b4–b4956c at 0xcddfd4–6980c6
Balance
0 mADA
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
28077734
Contract name:
ProxyFactory




Optimization enabled
true
Compiler version
v0.8.17+commit.8df45f5f




Optimization runs
1000
Verified at
2023-03-16T17:09:39.106568Z

Constructor Arguments

0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d76

Arg [0] (address) : 0x3dec619dc529363767dee9e71d8dd1a5bc270d76

              

contracts/api3-server-v1/proxies/ProxyFactory.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./DataFeedProxy.sol";
import "./DapiProxy.sol";
import "./DataFeedProxyWithOev.sol";
import "./DapiProxyWithOev.sol";
import "./interfaces/IProxyFactory.sol";
import "@openzeppelin/contracts/utils/Create2.sol";

/// @title Contract factory that deterministically deploys proxies that read
/// data feeds (Beacons or Beacon sets) or dAPIs, along with optional OEV
/// support
/// @dev The proxies are deployed normally and not cloned to minimize the gas
/// cost overhead while using them to read data feed values
contract ProxyFactory is IProxyFactory {
    /// @notice Api3ServerV1 address
    address public immutable override api3ServerV1;

    /// @param _api3ServerV1 Api3ServerV1 address
    constructor(address _api3ServerV1) {
        require(_api3ServerV1 != address(0), "Api3ServerV1 address zero");
        api3ServerV1 = _api3ServerV1;
    }

    /// @notice Deterministically deploys a data feed proxy
    /// @param dataFeedId Data feed ID
    /// @param metadata Metadata associated with the proxy
    /// @return proxyAddress Proxy address
    function deployDataFeedProxy(
        bytes32 dataFeedId,
        bytes calldata metadata
    ) external override returns (address proxyAddress) {
        require(dataFeedId != bytes32(0), "Data feed ID zero");
        proxyAddress = address(
            new DataFeedProxy{salt: keccak256(metadata)}(
                api3ServerV1,
                dataFeedId
            )
        );
        emit DeployedDataFeedProxy(proxyAddress, dataFeedId, metadata);
    }

    /// @notice Deterministically deploys a dAPI proxy
    /// @param dapiName dAPI name
    /// @param metadata Metadata associated with the proxy
    /// @return proxyAddress Proxy address
    function deployDapiProxy(
        bytes32 dapiName,
        bytes calldata metadata
    ) external override returns (address proxyAddress) {
        require(dapiName != bytes32(0), "dAPI name zero");
        proxyAddress = address(
            new DapiProxy{salt: keccak256(metadata)}(
                api3ServerV1,
                keccak256(abi.encodePacked(dapiName))
            )
        );
        emit DeployedDapiProxy(proxyAddress, dapiName, metadata);
    }

    /// @notice Deterministically deploys a data feed proxy with OEV support
    /// @param dataFeedId Data feed ID
    /// @param oevBeneficiary OEV beneficiary
    /// @param metadata Metadata associated with the proxy
    /// @return proxyAddress Proxy address
    function deployDataFeedProxyWithOev(
        bytes32 dataFeedId,
        address oevBeneficiary,
        bytes calldata metadata
    ) external override returns (address proxyAddress) {
        require(dataFeedId != bytes32(0), "Data feed ID zero");
        require(oevBeneficiary != address(0), "OEV beneficiary zero");
        proxyAddress = address(
            new DataFeedProxyWithOev{salt: keccak256(metadata)}(
                api3ServerV1,
                dataFeedId,
                oevBeneficiary
            )
        );
        emit DeployedDataFeedProxyWithOev(
            proxyAddress,
            dataFeedId,
            oevBeneficiary,
            metadata
        );
    }

    /// @notice Deterministically deploys a dAPI proxy with OEV support
    /// @param dapiName dAPI name
    /// @param oevBeneficiary OEV beneficiary
    /// @param metadata Metadata associated with the proxy
    /// @return proxyAddress Proxy address
    function deployDapiProxyWithOev(
        bytes32 dapiName,
        address oevBeneficiary,
        bytes calldata metadata
    ) external override returns (address proxyAddress) {
        require(dapiName != bytes32(0), "dAPI name zero");
        require(oevBeneficiary != address(0), "OEV beneficiary zero");
        proxyAddress = address(
            new DapiProxyWithOev{salt: keccak256(metadata)}(
                api3ServerV1,
                keccak256(abi.encodePacked(dapiName)),
                oevBeneficiary
            )
        );
        emit DeployedDapiProxyWithOev(
            proxyAddress,
            dapiName,
            oevBeneficiary,
            metadata
        );
    }

    /// @notice Computes the address of the data feed proxy
    /// @param dataFeedId Data feed ID
    /// @param metadata Metadata associated with the proxy
    /// @return proxyAddress Proxy address
    function computeDataFeedProxyAddress(
        bytes32 dataFeedId,
        bytes calldata metadata
    ) external view override returns (address proxyAddress) {
        require(dataFeedId != bytes32(0), "Data feed ID zero");
        proxyAddress = Create2.computeAddress(
            keccak256(metadata),
            keccak256(
                abi.encodePacked(
                    type(DataFeedProxy).creationCode,
                    abi.encode(api3ServerV1, dataFeedId)
                )
            )
        );
    }

    /// @notice Computes the address of the dAPI proxy
    /// @param dapiName dAPI name
    /// @param metadata Metadata associated with the proxy
    /// @return proxyAddress Proxy address
    function computeDapiProxyAddress(
        bytes32 dapiName,
        bytes calldata metadata
    ) external view override returns (address proxyAddress) {
        require(dapiName != bytes32(0), "dAPI name zero");
        proxyAddress = Create2.computeAddress(
            keccak256(metadata),
            keccak256(
                abi.encodePacked(
                    type(DapiProxy).creationCode,
                    abi.encode(
                        api3ServerV1,
                        keccak256(abi.encodePacked(dapiName))
                    )
                )
            )
        );
    }

    /// @notice Computes the address of the data feed proxy with OEV support
    /// @param dataFeedId Data feed ID
    /// @param oevBeneficiary OEV beneficiary
    /// @param metadata Metadata associated with the proxy
    /// @return proxyAddress Proxy address
    function computeDataFeedProxyWithOevAddress(
        bytes32 dataFeedId,
        address oevBeneficiary,
        bytes calldata metadata
    ) external view override returns (address proxyAddress) {
        require(dataFeedId != bytes32(0), "Data feed ID zero");
        require(oevBeneficiary != address(0), "OEV beneficiary zero");
        proxyAddress = Create2.computeAddress(
            keccak256(metadata),
            keccak256(
                abi.encodePacked(
                    type(DataFeedProxyWithOev).creationCode,
                    abi.encode(api3ServerV1, dataFeedId, oevBeneficiary)
                )
            )
        );
    }

    /// @notice Computes the address of the dAPI proxy with OEV support
    /// @param dapiName dAPI name
    /// @param oevBeneficiary OEV beneficiary
    /// @param metadata Metadata associated with the proxy
    /// @return proxyAddress Proxy address
    function computeDapiProxyWithOevAddress(
        bytes32 dapiName,
        address oevBeneficiary,
        bytes calldata metadata
    ) external view override returns (address proxyAddress) {
        require(dapiName != bytes32(0), "dAPI name zero");
        require(oevBeneficiary != address(0), "OEV beneficiary zero");
        proxyAddress = Create2.computeAddress(
            keccak256(metadata),
            keccak256(
                abi.encodePacked(
                    type(DapiProxyWithOev).creationCode,
                    abi.encode(
                        api3ServerV1,
                        keccak256(abi.encodePacked(dapiName)),
                        oevBeneficiary
                    )
                )
            )
        );
    }
}
        

contracts/access-control-registry/interfaces/IAccessControlRegistryAdminnedWithManager.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IAccessControlRegistryAdminned.sol";

interface IAccessControlRegistryAdminnedWithManager is
    IAccessControlRegistryAdminned
{
    function manager() external view returns (address);

    function adminRole() external view returns (bytes32);
}
          

@openzeppelin/contracts/utils/Create2.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Create2.sol)

pragma solidity ^0.8.0;

/**
 * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
 * `CREATE2` can be used to compute in advance the address where a smart
 * contract will be deployed, which allows for interesting new mechanisms known
 * as 'counterfactual interactions'.
 *
 * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
 * information.
 */
library Create2 {
    /**
     * @dev Deploys a contract using `CREATE2`. The address where the contract
     * will be deployed can be known in advance via {computeAddress}.
     *
     * The bytecode for a contract can be obtained from Solidity with
     * `type(contractName).creationCode`.
     *
     * Requirements:
     *
     * - `bytecode` must not be empty.
     * - `salt` must have not been used for `bytecode` already.
     * - the factory must have a balance of at least `amount`.
     * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
     */
    function deploy(
        uint256 amount,
        bytes32 salt,
        bytes memory bytecode
    ) internal returns (address addr) {
        require(address(this).balance >= amount, "Create2: insufficient balance");
        require(bytecode.length != 0, "Create2: bytecode length is zero");
        /// @solidity memory-safe-assembly
        assembly {
            addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
        }
        require(addr != address(0), "Create2: Failed on deploy");
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
     * `bytecodeHash` or `salt` will result in a new destination address.
     */
    function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
        return computeAddress(salt, bytecodeHash, address(this));
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
     * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
     */
    function computeAddress(
        bytes32 salt,
        bytes32 bytecodeHash,
        address deployer
    ) internal pure returns (address addr) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40) // Get free memory pointer

            // |                   | ↓ ptr ...  ↓ ptr + 0x0B (start) ...  ↓ ptr + 0x20 ...  ↓ ptr + 0x40 ...   |
            // |-------------------|---------------------------------------------------------------------------|
            // | bytecodeHash      |                                                        CCCCCCCCCCCCC...CC |
            // | salt              |                                      BBBBBBBBBBBBB...BB                   |
            // | deployer          | 000000...0000AAAAAAAAAAAAAAAAAAA...AA                                     |
            // | 0xFF              |            FF                                                             |
            // |-------------------|---------------------------------------------------------------------------|
            // | memory            | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |
            // | keccak(start, 85) |            ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |

            mstore(add(ptr, 0x40), bytecodeHash)
            mstore(add(ptr, 0x20), salt)
            mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes
            let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff
            mstore8(start, 0xff)
            addr := keccak256(start, 85)
        }
    }
}
          

contracts/access-control-registry/interfaces/IAccessControlRegistryAdminned.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../../utils/interfaces/ISelfMulticall.sol";

interface IAccessControlRegistryAdminned is ISelfMulticall {
    function accessControlRegistry() external view returns (address);

    function adminRoleDescription() external view returns (string memory);
}
          

contracts/api3-server-v1/interfaces/IApi3ServerV1.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IOevDapiServer.sol";
import "./IBeaconUpdatesWithSignedData.sol";

interface IApi3ServerV1 is IOevDapiServer, IBeaconUpdatesWithSignedData {
    function readDataFeedWithId(
        bytes32 dataFeedId
    ) external view returns (int224 value, uint32 timestamp);

    function readDataFeedWithDapiNameHash(
        bytes32 dapiNameHash
    ) external view returns (int224 value, uint32 timestamp);

    function readDataFeedWithIdAsOevProxy(
        bytes32 dataFeedId
    ) external view returns (int224 value, uint32 timestamp);

    function readDataFeedWithDapiNameHashAsOevProxy(
        bytes32 dapiNameHash
    ) external view returns (int224 value, uint32 timestamp);

    function dataFeeds(
        bytes32 dataFeedId
    ) external view returns (int224 value, uint32 timestamp);

    function oevProxyToIdToDataFeed(
        address proxy,
        bytes32 dataFeedId
    ) external view returns (int224 value, uint32 timestamp);
}
          

contracts/api3-server-v1/interfaces/IBeaconUpdatesWithSignedData.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IDataFeedServer.sol";

interface IBeaconUpdatesWithSignedData is IDataFeedServer {
    function updateBeaconWithSignedData(
        address airnode,
        bytes32 templateId,
        uint256 timestamp,
        bytes calldata data,
        bytes calldata signature
    ) external returns (bytes32 beaconId);
}
          

contracts/api3-server-v1/interfaces/IDapiServer.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../../access-control-registry/interfaces/IAccessControlRegistryAdminnedWithManager.sol";
import "./IDataFeedServer.sol";

interface IDapiServer is
    IAccessControlRegistryAdminnedWithManager,
    IDataFeedServer
{
    event SetDapiName(
        bytes32 indexed dataFeedId,
        bytes32 indexed dapiName,
        address sender
    );

    function setDapiName(bytes32 dapiName, bytes32 dataFeedId) external;

    function dapiNameToDataFeedId(
        bytes32 dapiName
    ) external view returns (bytes32);

    // solhint-disable-next-line func-name-mixedcase
    function DAPI_NAME_SETTER_ROLE_DESCRIPTION()
        external
        view
        returns (string memory);

    function dapiNameSetterRole() external view returns (bytes32);

    function dapiNameHashToDataFeedId(
        bytes32 dapiNameHash
    ) external view returns (bytes32 dataFeedId);
}
          

contracts/api3-server-v1/interfaces/IDataFeedServer.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../../utils/interfaces/IExtendedSelfMulticall.sol";

interface IDataFeedServer is IExtendedSelfMulticall {
    event UpdatedBeaconWithSignedData(
        bytes32 indexed beaconId,
        int224 value,
        uint32 timestamp
    );

    event UpdatedBeaconSetWithBeacons(
        bytes32 indexed beaconSetId,
        int224 value,
        uint32 timestamp
    );

    function updateBeaconSetWithBeacons(
        bytes32[] memory beaconIds
    ) external returns (bytes32 beaconSetId);
}
          

contracts/api3-server-v1/interfaces/IOevDapiServer.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IOevDataFeedServer.sol";
import "./IDapiServer.sol";

interface IOevDapiServer is IOevDataFeedServer, IDapiServer {}
          

contracts/api3-server-v1/interfaces/IOevDataFeedServer.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IDataFeedServer.sol";

interface IOevDataFeedServer is IDataFeedServer {
    event UpdatedOevProxyBeaconWithSignedData(
        bytes32 indexed beaconId,
        address indexed proxy,
        bytes32 indexed updateId,
        int224 value,
        uint32 timestamp
    );

    event UpdatedOevProxyBeaconSetWithSignedData(
        bytes32 indexed beaconSetId,
        address indexed proxy,
        bytes32 indexed updateId,
        int224 value,
        uint32 timestamp
    );

    event Withdrew(
        address indexed oevProxy,
        address oevBeneficiary,
        uint256 amount
    );

    function updateOevProxyDataFeedWithSignedData(
        address oevProxy,
        bytes32 dataFeedId,
        bytes32 updateId,
        uint256 timestamp,
        bytes calldata data,
        bytes[] calldata packedOevUpdateSignatures
    ) external payable;

    function withdraw(address oevProxy) external;

    function oevProxyToBalance(
        address oevProxy
    ) external view returns (uint256 balance);
}
          

contracts/api3-server-v1/proxies/DapiProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./interfaces/IDapiProxy.sol";
import "../interfaces/IApi3ServerV1.sol";

/// @title An immutable proxy contract that is used to read a specific dAPI of
/// a specific Api3ServerV1 contract
/// @notice In an effort to reduce the bytecode of this contract, its
/// constructor arguments are validated by ProxyFactory, rather than
/// internally. If you intend to deploy this contract without using
/// ProxyFactory, you are recommended to implement an equivalent validation.
/// @dev The proxy contracts are generalized to support most types of numerical
/// data feeds. This means that the user of this proxy is expected to validate
/// the read values according to the specific use-case. For example, `value` is
/// a signed integer, yet it being negative may not make sense in the case that
/// the data feed represents the spot price of an asset. In that case, the user
/// is responsible with ensuring that `value` is not negative.
/// In the case that the data feed is from a single source, `timestamp` is the
/// system time of the Airnode when it signed the data. In the case that the
/// data feed is from multiple sources, `timestamp` is the median of system
/// times of the Airnodes when they signed the respective data. There are two
/// points to consider while using `timestamp` in your contract logic: (1) It
/// is based on the system time of the Airnodes, and not the block timestamp.
/// This may be relevant when either of them drifts. (2) `timestamp` is an
/// off-chain value that is being reported, similar to `value`. Both should
/// only be trusted as much as the Airnode(s) that report them.
contract DapiProxy is IDapiProxy {
    /// @notice Api3ServerV1 address
    address public immutable override api3ServerV1;
    /// @notice Hash of the dAPI name
    bytes32 public immutable override dapiNameHash;

    /// @param _api3ServerV1 Api3ServerV1 address
    /// @param _dapiNameHash Hash of the dAPI name
    constructor(address _api3ServerV1, bytes32 _dapiNameHash) {
        api3ServerV1 = _api3ServerV1;
        dapiNameHash = _dapiNameHash;
    }

    /// @notice Reads the dAPI that this proxy maps to
    /// @return value dAPI value
    /// @return timestamp dAPI timestamp
    function read()
        external
        view
        virtual
        override
        returns (int224 value, uint32 timestamp)
    {
        (value, timestamp) = IApi3ServerV1(api3ServerV1)
            .readDataFeedWithDapiNameHash(dapiNameHash);
    }
}
          

contracts/api3-server-v1/proxies/DapiProxyWithOev.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./DapiProxy.sol";
import "./interfaces/IOevProxy.sol";

/// @title An immutable proxy contract that is used to read a specific dAPI of
/// a specific Api3ServerV1 contract and inform Api3ServerV1 about the
/// beneficiary of the respective OEV proceeds
/// @notice In an effort to reduce the bytecode of this contract, its
/// constructor arguments are validated by ProxyFactory, rather than
/// internally. If you intend to deploy this contract without using
/// ProxyFactory, you are recommended to implement an equivalent validation.
/// @dev See DapiProxy.sol for comments about usage
contract DapiProxyWithOev is DapiProxy, IOevProxy {
    /// @notice OEV beneficiary address
    address public immutable override oevBeneficiary;

    /// @param _api3ServerV1 Api3ServerV1 address
    /// @param _dapiNameHash Hash of the dAPI name
    /// @param _oevBeneficiary OEV beneficiary
    constructor(
        address _api3ServerV1,
        bytes32 _dapiNameHash,
        address _oevBeneficiary
    ) DapiProxy(_api3ServerV1, _dapiNameHash) {
        oevBeneficiary = _oevBeneficiary;
    }

    /// @notice Reads the dAPI that this proxy maps to
    /// @return value dAPI value
    /// @return timestamp dAPI timestamp
    function read()
        external
        view
        virtual
        override
        returns (int224 value, uint32 timestamp)
    {
        (value, timestamp) = IApi3ServerV1(api3ServerV1)
            .readDataFeedWithDapiNameHashAsOevProxy(dapiNameHash);
    }
}
          

contracts/api3-server-v1/proxies/DataFeedProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./interfaces/IDataFeedProxy.sol";
import "../interfaces/IApi3ServerV1.sol";

/// @title An immutable proxy contract that is used to read a specific data
/// feed (Beacon or Beacon set) of a specific Api3ServerV1 contract
/// @notice In an effort to reduce the bytecode of this contract, its
/// constructor arguments are validated by ProxyFactory, rather than
/// internally. If you intend to deploy this contract without using
/// ProxyFactory, you are recommended to implement an equivalent validation.
/// @dev See DapiProxy.sol for comments about usage
contract DataFeedProxy is IDataFeedProxy {
    /// @notice Api3ServerV1 address
    address public immutable override api3ServerV1;
    /// @notice Data feed ID
    bytes32 public immutable override dataFeedId;

    /// @param _api3ServerV1 Api3ServerV1 address
    /// @param _dataFeedId Data feed (Beacon or Beacon set) ID
    constructor(address _api3ServerV1, bytes32 _dataFeedId) {
        api3ServerV1 = _api3ServerV1;
        dataFeedId = _dataFeedId;
    }

    /// @notice Reads the data feed that this proxy maps to
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function read()
        external
        view
        virtual
        override
        returns (int224 value, uint32 timestamp)
    {
        (value, timestamp) = IApi3ServerV1(api3ServerV1).readDataFeedWithId(
            dataFeedId
        );
    }
}
          

contracts/api3-server-v1/proxies/DataFeedProxyWithOev.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./DataFeedProxy.sol";
import "./interfaces/IOevProxy.sol";

/// @title An immutable proxy contract that is used to read a specific data
/// feed (Beacon or Beacon set) of a specific Api3ServerV1 contract and inform
/// Api3ServerV1 about the beneficiary of the respective OEV proceeds
/// @notice In an effort to reduce the bytecode of this contract, its
/// constructor arguments are validated by ProxyFactory, rather than
/// internally. If you intend to deploy this contract without using
/// ProxyFactory, you are recommended to implement an equivalent validation.
/// @dev See DapiProxy.sol for comments about usage
contract DataFeedProxyWithOev is DataFeedProxy, IOevProxy {
    /// @notice OEV beneficiary address
    address public immutable override oevBeneficiary;

    /// @param _api3ServerV1 Api3ServerV1 address
    /// @param _dataFeedId Data feed (Beacon or Beacon set) ID
    /// @param _oevBeneficiary OEV beneficiary
    constructor(
        address _api3ServerV1,
        bytes32 _dataFeedId,
        address _oevBeneficiary
    ) DataFeedProxy(_api3ServerV1, _dataFeedId) {
        oevBeneficiary = _oevBeneficiary;
    }

    /// @notice Reads the data feed that this proxy maps to
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function read()
        external
        view
        virtual
        override
        returns (int224 value, uint32 timestamp)
    {
        (value, timestamp) = IApi3ServerV1(api3ServerV1)
            .readDataFeedWithIdAsOevProxy(dataFeedId);
    }
}
          

contracts/api3-server-v1/proxies/interfaces/IDapiProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IProxy.sol";

interface IDapiProxy is IProxy {
    function dapiNameHash() external view returns (bytes32);
}
          

contracts/api3-server-v1/proxies/interfaces/IDataFeedProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IProxy.sol";

interface IDataFeedProxy is IProxy {
    function dataFeedId() external view returns (bytes32);
}
          

contracts/api3-server-v1/proxies/interfaces/IOevProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IOevProxy {
    function oevBeneficiary() external view returns (address);
}
          

contracts/api3-server-v1/proxies/interfaces/IProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @dev See DapiProxy.sol for comments about usage
interface IProxy {
    function read() external view returns (int224 value, uint32 timestamp);

    function api3ServerV1() external view returns (address);
}
          

contracts/api3-server-v1/proxies/interfaces/IProxyFactory.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IProxyFactory {
    event DeployedDataFeedProxy(
        address indexed proxyAddress,
        bytes32 indexed dataFeedId,
        bytes metadata
    );

    event DeployedDapiProxy(
        address indexed proxyAddress,
        bytes32 indexed dapiName,
        bytes metadata
    );

    event DeployedDataFeedProxyWithOev(
        address indexed proxyAddress,
        bytes32 indexed dataFeedId,
        address oevBeneficiary,
        bytes metadata
    );

    event DeployedDapiProxyWithOev(
        address indexed proxyAddress,
        bytes32 indexed dapiName,
        address oevBeneficiary,
        bytes metadata
    );

    function deployDataFeedProxy(
        bytes32 dataFeedId,
        bytes calldata metadata
    ) external returns (address proxyAddress);

    function deployDapiProxy(
        bytes32 dapiName,
        bytes calldata metadata
    ) external returns (address proxyAddress);

    function deployDataFeedProxyWithOev(
        bytes32 dataFeedId,
        address oevBeneficiary,
        bytes calldata metadata
    ) external returns (address proxyAddress);

    function deployDapiProxyWithOev(
        bytes32 dapiName,
        address oevBeneficiary,
        bytes calldata metadata
    ) external returns (address proxyAddress);

    function computeDataFeedProxyAddress(
        bytes32 dataFeedId,
        bytes calldata metadata
    ) external view returns (address proxyAddress);

    function computeDapiProxyAddress(
        bytes32 dapiName,
        bytes calldata metadata
    ) external view returns (address proxyAddress);

    function computeDataFeedProxyWithOevAddress(
        bytes32 dataFeedId,
        address oevBeneficiary,
        bytes calldata metadata
    ) external view returns (address proxyAddress);

    function computeDapiProxyWithOevAddress(
        bytes32 dapiName,
        address oevBeneficiary,
        bytes calldata metadata
    ) external view returns (address proxyAddress);

    function api3ServerV1() external view returns (address);
}
          

contracts/utils/interfaces/IExtendedSelfMulticall.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./ISelfMulticall.sol";

interface IExtendedSelfMulticall is ISelfMulticall {
    function getChainId() external view returns (uint256);

    function getBalance(address account) external view returns (uint256);

    function containsBytecode(address account) external view returns (bool);

    function getBlockNumber() external view returns (uint256);

    function getBlockTimestamp() external view returns (uint256);

    function getBlockBasefee() external view returns (uint256);
}
          

contracts/utils/interfaces/ISelfMulticall.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ISelfMulticall {
    function multicall(
        bytes[] calldata data
    ) external returns (bytes[] memory returndata);

    function tryMulticall(
        bytes[] calldata data
    ) external returns (bool[] memory successes, bytes[] memory returndata);
}
          

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_api3ServerV1","internalType":"address"}]},{"type":"event","name":"DeployedDapiProxy","inputs":[{"type":"address","name":"proxyAddress","internalType":"address","indexed":true},{"type":"bytes32","name":"dapiName","internalType":"bytes32","indexed":true},{"type":"bytes","name":"metadata","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"DeployedDapiProxyWithOev","inputs":[{"type":"address","name":"proxyAddress","internalType":"address","indexed":true},{"type":"bytes32","name":"dapiName","internalType":"bytes32","indexed":true},{"type":"address","name":"oevBeneficiary","internalType":"address","indexed":false},{"type":"bytes","name":"metadata","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"DeployedDataFeedProxy","inputs":[{"type":"address","name":"proxyAddress","internalType":"address","indexed":true},{"type":"bytes32","name":"dataFeedId","internalType":"bytes32","indexed":true},{"type":"bytes","name":"metadata","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"DeployedDataFeedProxyWithOev","inputs":[{"type":"address","name":"proxyAddress","internalType":"address","indexed":true},{"type":"bytes32","name":"dataFeedId","internalType":"bytes32","indexed":true},{"type":"address","name":"oevBeneficiary","internalType":"address","indexed":false},{"type":"bytes","name":"metadata","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"api3ServerV1","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"proxyAddress","internalType":"address"}],"name":"computeDapiProxyAddress","inputs":[{"type":"bytes32","name":"dapiName","internalType":"bytes32"},{"type":"bytes","name":"metadata","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"proxyAddress","internalType":"address"}],"name":"computeDapiProxyWithOevAddress","inputs":[{"type":"bytes32","name":"dapiName","internalType":"bytes32"},{"type":"address","name":"oevBeneficiary","internalType":"address"},{"type":"bytes","name":"metadata","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"proxyAddress","internalType":"address"}],"name":"computeDataFeedProxyAddress","inputs":[{"type":"bytes32","name":"dataFeedId","internalType":"bytes32"},{"type":"bytes","name":"metadata","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"proxyAddress","internalType":"address"}],"name":"computeDataFeedProxyWithOevAddress","inputs":[{"type":"bytes32","name":"dataFeedId","internalType":"bytes32"},{"type":"address","name":"oevBeneficiary","internalType":"address"},{"type":"bytes","name":"metadata","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"proxyAddress","internalType":"address"}],"name":"deployDapiProxy","inputs":[{"type":"bytes32","name":"dapiName","internalType":"bytes32"},{"type":"bytes","name":"metadata","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"proxyAddress","internalType":"address"}],"name":"deployDapiProxyWithOev","inputs":[{"type":"bytes32","name":"dapiName","internalType":"bytes32"},{"type":"address","name":"oevBeneficiary","internalType":"address"},{"type":"bytes","name":"metadata","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"proxyAddress","internalType":"address"}],"name":"deployDataFeedProxy","inputs":[{"type":"bytes32","name":"dataFeedId","internalType":"bytes32"},{"type":"bytes","name":"metadata","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"proxyAddress","internalType":"address"}],"name":"deployDataFeedProxyWithOev","inputs":[{"type":"bytes32","name":"dataFeedId","internalType":"bytes32"},{"type":"address","name":"oevBeneficiary","internalType":"address"},{"type":"bytes","name":"metadata","internalType":"bytes"}]}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100a35760003560e01c80637dba7458116100765780639ae06c841161005b5780639ae06c841461014a578063d67564bd1461015d578063da1b7d0f1461017057600080fd5b80637dba7458146101245780638dae1a471461013757600080fd5b80632d6a744e146100a857806350763e84146100eb5780635849e5ef146100fe5780636c9d6c0914610111575b600080fd5b6100cf7f0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d7681565b6040516001600160a01b03909116815260200160405180910390f35b6100cf6100f9366004610b72565b610183565b6100cf61010c366004610bbe565b610282565b6100cf61011f366004610bbe565b61040f565b6100cf610132366004610b72565b610547565b6100cf610145366004610bbe565b610653565b6100cf610158366004610b72565b6107ab565b6100cf61016b366004610bbe565b6108cd565b6100cf61017e366004610b72565b6109e1565b6000836101cb5760405162461bcd60e51b8152602060048201526011602482015270446174612066656564204944207a65726f60781b60448201526064015b60405180910390fd5b61027a83836040516101de929190610c26565b604051908190038120906101f460208201610af5565b601f1982820381018352601f9091011660408181527f0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d766001600160a01b0316602083015281018890526060015b60408051601f198184030181529082905261025f9291602001610c66565b60405160208183030381529060405280519060200120610ab7565b949350505050565b6000846102c25760405162461bcd60e51b815260206004820152600e60248201526d64415049206e616d65207a65726f60901b60448201526064016101c2565b6001600160a01b03841661030f5760405162461bcd60e51b81526020600482015260146024820152734f45562062656e6566696369617279207a65726f60601b60448201526064016101c2565b828260405161031f929190610c26565b60405180910390207f0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d768660405160200161035b91815260200190565b604051602081830303815290604052805190602001208660405161037e90610b02565b6001600160a01b039384168152602081019290925290911660408201526060018190604051809103906000f59050801580156103be573d6000803e3d6000fd5b50905084816001600160a01b03167f31d654553da13df7303eb8db83942ff8816845087d3149515a220f5afb37aedd8686866040516103ff93929190610ca4565b60405180910390a3949350505050565b60008461044f5760405162461bcd60e51b815260206004820152600e60248201526d64415049206e616d65207a65726f60901b60448201526064016101c2565b6001600160a01b03841661049c5760405162461bcd60e51b81526020600482015260146024820152734f45562062656e6566696369617279207a65726f60601b60448201526064016101c2565b61053e83836040516104af929190610c26565b604051908190038120906104c560208201610b02565b818103601f199081018352601f90910116604081815260208083018b905281518084038201815282840190925281519101206001600160a01b037f0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d76811660608401526080830191909152881660a082015260c001610241565b95945050505050565b60008361058a5760405162461bcd60e51b8152602060048201526011602482015270446174612066656564204944207a65726f60781b60448201526064016101c2565b828260405161059a929190610c26565b60405180910390207f0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d76856040516105d090610af5565b6001600160a01b03909216825260208201526040018190604051809103906000f5905080158015610605573d6000803e3d6000fd5b50905083816001600160a01b03167f9a2a9d77287e93a2addaf0c5f3e354d075dfb475f5e197f9abc9b11b922fa9438585604051610644929190610cc7565b60405180910390a39392505050565b6000846106965760405162461bcd60e51b8152602060048201526011602482015270446174612066656564204944207a65726f60781b60448201526064016101c2565b6001600160a01b0384166106e35760405162461bcd60e51b81526020600482015260146024820152734f45562062656e6566696369617279207a65726f60601b60448201526064016101c2565b82826040516106f3929190610c26565b60405180910390207f0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d76868660405161072a90610b0f565b6001600160a01b039384168152602081019290925290911660408201526060018190604051809103906000f590508015801561076a573d6000803e3d6000fd5b50905084816001600160a01b03167fff915717e95cf852fef69474bc2bfb3c26ccc15a6978a90ab0a78bc565644d4e8686866040516103ff93929190610ca4565b6000836107eb5760405162461bcd60e51b815260206004820152600e60248201526d64415049206e616d65207a65726f60901b60448201526064016101c2565b82826040516107fb929190610c26565b60405180910390207f0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d768560405160200161083791815260200190565b6040516020818303038152906040528051906020012060405161085990610b1c565b6001600160a01b03909216825260208201526040018190604051809103906000f590508015801561088e573d6000803e3d6000fd5b50905083816001600160a01b03167f5212a04ae578b0432469e3d61a28f222c00cf2f5e14d69b0f08c7d327b623d1d8585604051610644929190610cc7565b6000846109105760405162461bcd60e51b8152602060048201526011602482015270446174612066656564204944207a65726f60781b60448201526064016101c2565b6001600160a01b03841661095d5760405162461bcd60e51b81526020600482015260146024820152734f45562062656e6566696369617279207a65726f60601b60448201526064016101c2565b61053e8383604051610970929190610c26565b6040519081900381209061098660208201610b0f565b818103601f199081018352601f9091011660408181526001600160a01b037f0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d76811660208401529082018a905288166060820152608001610241565b600083610a215760405162461bcd60e51b815260206004820152600e60248201526d64415049206e616d65207a65726f60901b60448201526064016101c2565b61027a8383604051610a34929190610c26565b60405190819003812090610a4a60208201610b1c565b601f1982820381018352601f90910116604081815260208083018a905281518084038201815282840190925281519101207f0000000000000000000000003dec619dc529363767dee9e71d8dd1a5bc270d766001600160a01b03166060830152608082015260a001610241565b6000610ac4838330610acb565b9392505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b6102fd80610cdc83390190565b61035d80610fd983390190565b61035d8061133683390190565b6102fd8061169383390190565b60008083601f840112610b3b57600080fd5b50813567ffffffffffffffff811115610b5357600080fd5b602083019150836020828501011115610b6b57600080fd5b9250929050565b600080600060408486031215610b8757600080fd5b83359250602084013567ffffffffffffffff811115610ba557600080fd5b610bb186828701610b29565b9497909650939450505050565b60008060008060608587031215610bd457600080fd5b8435935060208501356001600160a01b0381168114610bf257600080fd5b9250604085013567ffffffffffffffff811115610c0e57600080fd5b610c1a87828801610b29565b95989497509550505050565b8183823760009101908152919050565b6000815160005b81811015610c575760208185018101518683015201610c3d565b50600093019283525090919050565b600061027a610c758386610c36565b84610c36565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b038416815260406020820152600061053e604083018486610c7b565b60208152600061027a602083018486610c7b56fe60c060405234801561001057600080fd5b506040516102fd3803806102fd83398101604081905261002f91610045565b6001600160a01b0390911660805260a05261007f565b6000806040838503121561005857600080fd5b82516001600160a01b038116811461006f57600080fd5b6020939093015192949293505050565b60805160a05161024d6100b060003960008181609c015261011b015260008181604b015261015b015261024d6000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80632d6a744e14610046578063370c826b1461009757806357de26a4146100cc575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100be7f000000000000000000000000000000000000000000000000000000000000000081565b60405190815260200161008e565b6100d46100f3565b60408051601b9390930b835263ffffffff90911660208301520161008e565b6040517fa5fc076f0000000000000000000000000000000000000000000000000000000081527f00000000000000000000000000000000000000000000000000000000000000006004820152600090819073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063a5fc076f906024016040805180830381865afa1580156101a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c591906101ce565b90939092509050565b600080604083850312156101e157600080fd5b825180601b0b81146101f257600080fd5b602084015190925063ffffffff8116811461020c57600080fd5b80915050925092905056fea26469706673582212204c00c55f37d9d93afc24a97a86b86c67275c3e6f0288edd31c678400d06b4dcc64736f6c6343000811003360e060405234801561001057600080fd5b5060405161035d38038061035d83398101604081905261002f91610068565b6001600160a01b0392831660805260a0919091521660c0526100a4565b80516001600160a01b038116811461006357600080fd5b919050565b60008060006060848603121561007d57600080fd5b6100868461004c565b92506020840151915061009b6040850161004c565b90509250925092565b60805160a05160c05161027f6100de6000396000605601526000818160f5015261014d01526000818160a7015261018d015261027f6000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630e15999d146100515780632d6a744e146100a257806357de26a4146100c9578063dcf8da92146100f0575b600080fd5b6100787f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100787f000000000000000000000000000000000000000000000000000000000000000081565b6100d1610125565b60408051601b9390930b835263ffffffff909116602083015201610099565b6101177f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610099565b6040517f32be8f0b0000000000000000000000000000000000000000000000000000000081527f00000000000000000000000000000000000000000000000000000000000000006004820152600090819073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016906332be8f0b906024016040805180830381865afa1580156101d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101f79190610200565b90939092509050565b6000806040838503121561021357600080fd5b825180601b0b811461022457600080fd5b602084015190925063ffffffff8116811461023e57600080fd5b80915050925092905056fea2646970667358221220165f090121acbfb6f16face0e037df12b601e08d2e0fd3fd3f5e021e053308ce64736f6c6343000811003360e060405234801561001057600080fd5b5060405161035d38038061035d83398101604081905261002f91610068565b6001600160a01b0392831660805260a0919091521660c0526100a4565b80516001600160a01b038116811461006357600080fd5b919050565b60008060006060848603121561007d57600080fd5b6100868461004c565b92506020840151915061009b6040850161004c565b90509250925092565b60805160a05160c05161027f6100de6000396000605601526000818160ce015261014d01526000818160a7015261018d015261027f6000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630e15999d146100515780632d6a744e146100a2578063370c826b146100c957806357de26a4146100fe575b600080fd5b6100787f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100787f000000000000000000000000000000000000000000000000000000000000000081565b6100f07f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610099565b610106610125565b60408051601b9390930b835263ffffffff909116602083015201610099565b6040517fcfaf49710000000000000000000000000000000000000000000000000000000081527f00000000000000000000000000000000000000000000000000000000000000006004820152600090819073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063cfaf4971906024016040805180830381865afa1580156101d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101f79190610200565b90939092509050565b6000806040838503121561021357600080fd5b825180601b0b811461022457600080fd5b602084015190925063ffffffff8116811461023e57600080fd5b80915050925092905056fea2646970667358221220491c4b81100c410951a4eacc896ef33bf2f2865d87768147c4ca7217d63d79c864736f6c6343000811003360c060405234801561001057600080fd5b506040516102fd3803806102fd83398101604081905261002f91610045565b6001600160a01b0390911660805260a05261007f565b6000806040838503121561005857600080fd5b82516001600160a01b038116811461006f57600080fd5b6020939093015192949293505050565b60805160a05161024d6100b06000396000818160c3015261011b015260008181604b015261015b015261024d6000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80632d6a744e1461004657806357de26a414610097578063dcf8da92146100be575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61009f6100f3565b60408051601b9390930b835263ffffffff90911660208301520161008e565b6100e57f000000000000000000000000000000000000000000000000000000000000000081565b60405190815260200161008e565b6040517fb62408a30000000000000000000000000000000000000000000000000000000081527f00000000000000000000000000000000000000000000000000000000000000006004820152600090819073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063b62408a3906024016040805180830381865afa1580156101a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c591906101ce565b90939092509050565b600080604083850312156101e157600080fd5b825180601b0b81146101f257600080fd5b602084015190925063ffffffff8116811461020c57600080fd5b80915050925092905056fea26469706673582212201d061d50f160b049953a990ae61794869544bc65e5a0d25812e444c431cb90f964736f6c63430008110033a2646970667358221220c65d86e8fe1882ee9717fe8fadf286e2319482a7213942b09ed85c68e3cb244164736f6c63430008110033