APE Price: $1.16 (+4.85%)

Contract

0x709944a48cAf83535e43471680fDA4905FB3920a

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo0 APE

APE Value

$0.00
Transaction Hash
Method
Block
From
To
Try Multicall48920332024-11-21 15:38:0613 mins ago1732203486IN
0x709944a4...05FB3920a
0 APE0.0044676625.42069
Try Multicall48917642024-11-21 15:34:0617 mins ago1732203246IN
0x709944a4...05FB3920a
0 APE0.0044685525.42069
Try Multicall48914982024-11-21 15:30:0621 mins ago1732203006IN
0x709944a4...05FB3920a
0 APE0.0044572325.42069
Try Multicall48913102024-11-21 15:27:2624 mins ago1732202846IN
0x709944a4...05FB3920a
0 APE0.0044743925.42069
Try Multicall48907962024-11-21 15:19:5731 mins ago1732202397IN
0x709944a4...05FB3920a
0 APE0.0044565525.42069
Try Multicall48902172024-11-21 15:12:3039 mins ago1732201950IN
0x709944a4...05FB3920a
0 APE0.0044345625.42069
Try Multicall48889202024-11-21 14:55:4155 mins ago1732200941IN
0x709944a4...05FB3920a
0 APE0.0044618125.42069
Try Multicall48882242024-11-21 14:47:321 hr ago1732200452IN
0x709944a4...05FB3920a
0 APE0.0044449325.42069
Try Multicall48878162024-11-21 14:41:171 hr ago1732200077IN
0x709944a4...05FB3920a
0 APE0.0044621425.42069
Try Multicall48874212024-11-21 14:36:301 hr ago1732199790IN
0x709944a4...05FB3920a
0 APE0.0044501425.42069
Try Multicall48846102024-11-21 13:57:391 hr ago1732197459IN
0x709944a4...05FB3920a
0 APE0.0044621125.42069
Try Multicall48843202024-11-21 13:53:161 hr ago1732197196IN
0x709944a4...05FB3920a
0 APE0.0044566225.42069
Try Multicall48815242024-11-21 13:12:192 hrs ago1732194739IN
0x709944a4...05FB3920a
0 APE0.0044636425.42069
Try Multicall48813132024-11-21 13:09:332 hrs ago1732194573IN
0x709944a4...05FB3920a
0 APE0.0044679125.42069
Try Multicall48795442024-11-21 12:45:383 hrs ago1732193138IN
0x709944a4...05FB3920a
0 APE0.0044563225.42069
Try Multicall48793852024-11-21 12:43:393 hrs ago1732193019IN
0x709944a4...05FB3920a
0 APE0.0044575425.42069
Try Multicall48782282024-11-21 12:25:473 hrs ago1732191947IN
0x709944a4...05FB3920a
0 APE0.0044749825.42069
Try Multicall48781742024-11-21 12:25:063 hrs ago1732191906IN
0x709944a4...05FB3920a
0 APE0.0044501225.42069
Try Multicall48777382024-11-21 12:18:203 hrs ago1732191500IN
0x709944a4...05FB3920a
0 APE0.0044694425.42069
Try Multicall48776462024-11-21 12:17:013 hrs ago1732191421IN
0x709944a4...05FB3920a
0 APE0.0044620925.42069
Try Multicall48773912024-11-21 12:13:223 hrs ago1732191202IN
0x709944a4...05FB3920a
0 APE0.0044507525.42069
Try Multicall48768492024-11-21 12:06:103 hrs ago1732190770IN
0x709944a4...05FB3920a
0 APE0.0044639425.42069
Try Multicall48748522024-11-21 11:41:164 hrs ago1732189276IN
0x709944a4...05FB3920a
0 APE0.0044740425.42069
Try Multicall48695442024-11-21 10:29:165 hrs ago1732184956IN
0x709944a4...05FB3920a
0 APE0.0045015925.42069
Try Multicall48674052024-11-21 9:57:375 hrs ago1732183057IN
0x709944a4...05FB3920a
0 APE0.0044663825.42069
View all transactions

Latest 1 internal transaction

Parent Transaction Hash Block From To
36700132024-11-06 12:40:2415 days ago1730896824  Contract Creation0 APE

Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x3ee097B8...686247Ff2
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
Api3ServerV1

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 30 : Api3ServerV1.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "./OevDapiServer.sol";
import "./BeaconUpdatesWithSignedData.sol";
import "./interfaces/IApi3ServerV1.sol";

/// @title First version of the contract that API3 uses to serve data feeds
/// @notice Api3ServerV1 serves data feeds in the form of Beacons, Beacon sets,
/// dAPIs, with optional OEV support for all of these.
/// The base Beacons are only updateable using signed data, and the Beacon sets
/// are updateable based on the Beacons, optionally using PSP. OEV proxy
/// Beacons and Beacon sets are updateable using OEV-signed data.
/// Api3ServerV1 does not support Beacons to be updated using RRP or PSP.
contract Api3ServerV1 is
    OevDapiServer,
    BeaconUpdatesWithSignedData,
    IApi3ServerV1
{
    /// @param _accessControlRegistry AccessControlRegistry contract address
    /// @param _adminRoleDescription Admin role description
    /// @param _manager Manager address
    constructor(
        address _accessControlRegistry,
        string memory _adminRoleDescription,
        address _manager
    ) OevDapiServer(_accessControlRegistry, _adminRoleDescription, _manager) {}

    /// @notice Reads the data feed with ID
    /// @param dataFeedId Data feed ID
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function readDataFeedWithId(
        bytes32 dataFeedId
    ) external view override returns (int224 value, uint32 timestamp) {
        return _readDataFeedWithId(dataFeedId);
    }

    /// @notice Reads the data feed with dAPI name hash
    /// @param dapiNameHash dAPI name hash
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function readDataFeedWithDapiNameHash(
        bytes32 dapiNameHash
    ) external view override returns (int224 value, uint32 timestamp) {
        return _readDataFeedWithDapiNameHash(dapiNameHash);
    }

    /// @notice Reads the data feed as the OEV proxy with ID
    /// @param dataFeedId Data feed ID
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function readDataFeedWithIdAsOevProxy(
        bytes32 dataFeedId
    ) external view override returns (int224 value, uint32 timestamp) {
        return _readDataFeedWithIdAsOevProxy(dataFeedId);
    }

    /// @notice Reads the data feed as the OEV proxy with dAPI name hash
    /// @param dapiNameHash dAPI name hash
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function readDataFeedWithDapiNameHashAsOevProxy(
        bytes32 dapiNameHash
    ) external view override returns (int224 value, uint32 timestamp) {
        return _readDataFeedWithDapiNameHashAsOevProxy(dapiNameHash);
    }

    function dataFeeds(
        bytes32 dataFeedId
    ) external view override returns (int224 value, uint32 timestamp) {
        DataFeed storage dataFeed = _dataFeeds[dataFeedId];
        (value, timestamp) = (dataFeed.value, dataFeed.timestamp);
    }

    function oevProxyToIdToDataFeed(
        address proxy,
        bytes32 dataFeedId
    ) external view override returns (int224 value, uint32 timestamp) {
        DataFeed storage dataFeed = _oevProxyToIdToDataFeed[proxy][dataFeedId];
        (value, timestamp) = (dataFeed.value, dataFeed.timestamp);
    }
}

File 2 of 30 : AccessControlRegistryAdminned.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../utils/SelfMulticall.sol";
import "./RoleDeriver.sol";
import "./interfaces/IAccessControlRegistryAdminned.sol";
import "./interfaces/IAccessControlRegistry.sol";

/// @title Contract to be inherited by contracts whose adminship functionality
/// will be implemented using AccessControlRegistry
contract AccessControlRegistryAdminned is
    SelfMulticall,
    RoleDeriver,
    IAccessControlRegistryAdminned
{
    /// @notice AccessControlRegistry contract address
    address public immutable override accessControlRegistry;

    /// @notice Admin role description
    string public override adminRoleDescription;

    bytes32 internal immutable adminRoleDescriptionHash;

    /// @dev Contracts deployed with the same admin role descriptions will have
    /// the same roles, meaning that granting an account a role will authorize
    /// it in multiple contracts. Unless you want your deployed contract to
    /// share the role configuration of another contract, use a unique admin
    /// role description.
    /// @param _accessControlRegistry AccessControlRegistry contract address
    /// @param _adminRoleDescription Admin role description
    constructor(
        address _accessControlRegistry,
        string memory _adminRoleDescription
    ) {
        require(_accessControlRegistry != address(0), "ACR address zero");
        require(
            bytes(_adminRoleDescription).length > 0,
            "Admin role description empty"
        );
        accessControlRegistry = _accessControlRegistry;
        adminRoleDescription = _adminRoleDescription;
        adminRoleDescriptionHash = keccak256(
            abi.encodePacked(_adminRoleDescription)
        );
    }

    /// @notice Derives the admin role for the specific manager address
    /// @param manager Manager address
    /// @return adminRole Admin role
    function _deriveAdminRole(
        address manager
    ) internal view returns (bytes32 adminRole) {
        adminRole = _deriveRole(
            _deriveRootRole(manager),
            adminRoleDescriptionHash
        );
    }
}

File 3 of 30 : AccessControlRegistryAdminnedWithManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./AccessControlRegistryAdminned.sol";
import "./interfaces/IAccessControlRegistryAdminnedWithManager.sol";

/// @title Contract to be inherited by contracts with manager whose adminship
/// functionality will be implemented using AccessControlRegistry
/// @notice The manager address here is expected to belong to an
/// AccessControlRegistry user that is a multisig/DAO
contract AccessControlRegistryAdminnedWithManager is
    AccessControlRegistryAdminned,
    IAccessControlRegistryAdminnedWithManager
{
    /// @notice Address of the manager that manages the related
    /// AccessControlRegistry roles
    /// @dev The mutability of the manager role can be implemented by
    /// designating an OwnableCallForwarder contract as the manager. The
    /// ownership of this contract can then be transferred, effectively
    /// transferring managership.
    address public immutable override manager;

    /// @notice Admin role
    /// @dev Since `manager` is immutable, so is `adminRole`
    bytes32 public immutable override adminRole;

    /// @param _accessControlRegistry AccessControlRegistry contract address
    /// @param _adminRoleDescription Admin role description
    /// @param _manager Manager address
    constructor(
        address _accessControlRegistry,
        string memory _adminRoleDescription,
        address _manager
    )
        AccessControlRegistryAdminned(
            _accessControlRegistry,
            _adminRoleDescription
        )
    {
        require(_manager != address(0), "Manager address zero");
        manager = _manager;
        adminRole = _deriveAdminRole(_manager);
    }
}

File 4 of 30 : IAccessControlRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../../vendor/@openzeppelin/[email protected]/access/IAccessControl.sol";
import "../../utils/interfaces/ISelfMulticall.sol";

interface IAccessControlRegistry is IAccessControl, ISelfMulticall {
    event InitializedManager(
        bytes32 indexed rootRole,
        address indexed manager,
        address sender
    );

    event InitializedRole(
        bytes32 indexed role,
        bytes32 indexed adminRole,
        string description,
        address sender
    );

    function initializeManager(address manager) external;

    function initializeRoleAndGrantToSender(
        bytes32 adminRole,
        string calldata description
    ) external returns (bytes32 role);
}

File 5 of 30 : 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);
}

File 6 of 30 : 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);
}

File 7 of 30 : RoleDeriver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Contract to be inherited by contracts that will derive
/// AccessControlRegistry roles
/// @notice If a contract interfaces with AccessControlRegistry and needs to
/// derive roles, it should inherit this contract instead of re-implementing
/// the logic
contract RoleDeriver {
    /// @notice Derives the root role of the manager
    /// @param manager Manager address
    /// @return rootRole Root role
    function _deriveRootRole(
        address manager
    ) internal pure returns (bytes32 rootRole) {
        rootRole = keccak256(abi.encodePacked(manager));
    }

    /// @notice Derives the role using its admin role and description
    /// @dev This implies that roles adminned by the same role cannot have the
    /// same description
    /// @param adminRole Admin role
    /// @param description Human-readable description of the role
    /// @return role Role
    function _deriveRole(
        bytes32 adminRole,
        string memory description
    ) internal pure returns (bytes32 role) {
        role = _deriveRole(adminRole, keccak256(abi.encodePacked(description)));
    }

    /// @notice Derives the role using its admin role and description hash
    /// @dev This implies that roles adminned by the same role cannot have the
    /// same description
    /// @param adminRole Admin role
    /// @param descriptionHash Hash of the human-readable description of the
    /// role
    /// @return role Role
    function _deriveRole(
        bytes32 adminRole,
        bytes32 descriptionHash
    ) internal pure returns (bytes32 role) {
        role = keccak256(abi.encodePacked(adminRole, descriptionHash));
    }
}

File 8 of 30 : Median.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./Sort.sol";
import "./QuickSelect.sol";

/// @title Contract to be inherited by contracts that will calculate the median
/// of an array
/// @notice The operation will be in-place, i.e., the array provided as the
/// argument will be modified.
contract Median is Sort, Quickselect {
    /// @notice Returns the median of the array
    /// @dev Uses an unrolled sorting implementation for shorter arrays and
    /// quickselect for longer arrays for gas cost efficiency
    /// @param array Array whose median is to be calculated
    /// @return Median of the array
    function median(int256[] memory array) internal pure returns (int256) {
        uint256 arrayLength = array.length;
        if (arrayLength <= MAX_SORT_LENGTH) {
            sort(array);
            if (arrayLength % 2 == 1) {
                return array[arrayLength / 2];
            } else {
                assert(arrayLength != 0);
                unchecked {
                    return
                        average(
                            array[arrayLength / 2 - 1],
                            array[arrayLength / 2]
                        );
                }
            }
        } else {
            if (arrayLength % 2 == 1) {
                return array[quickselectK(array, arrayLength / 2)];
            } else {
                uint256 mid1;
                uint256 mid2;
                unchecked {
                    (mid1, mid2) = quickselectKPlusOne(
                        array,
                        arrayLength / 2 - 1
                    );
                }
                return average(array[mid1], array[mid2]);
            }
        }
    }

    /// @notice Averages two signed integers without overflowing
    /// @param x Integer x
    /// @param y Integer y
    /// @return Average of integers x and y
    function average(int256 x, int256 y) private pure returns (int256) {
        unchecked {
            int256 averageRoundedDownToNegativeInfinity = (x >> 1) +
                (y >> 1) +
                (x & y & 1);
            // If the average rounded down to negative infinity is negative
            // (i.e., its 256th sign bit is set), and one of (x, y) is even and
            // the other one is odd (i.e., the 1st bit of their xor is set),
            // add 1 to round the average down to zero instead.
            // We will typecast the signed integer to unsigned to logical-shift
            // int256(uint256(signedInt)) >> 255 ~= signedInt >>> 255
            return
                averageRoundedDownToNegativeInfinity +
                (int256(
                    (uint256(averageRoundedDownToNegativeInfinity) >> 255)
                ) & (x ^ y));
        }
    }
}

File 9 of 30 : QuickSelect.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Contract to be inherited by contracts that will calculate the index
/// of the k-th and optionally (k+1)-th largest elements in the array
/// @notice Uses quickselect, which operates in-place, i.e., the array provided
/// as the argument will be modified.
contract Quickselect {
    /// @notice Returns the index of the k-th largest element in the array
    /// @param array Array in which k-th largest element will be searched
    /// @param k K
    /// @return indK Index of the k-th largest element
    function quickselectK(
        int256[] memory array,
        uint256 k
    ) internal pure returns (uint256 indK) {
        uint256 arrayLength = array.length;
        assert(arrayLength > 0);
        unchecked {
            (indK, ) = quickselect(array, 0, arrayLength - 1, k, false);
        }
    }

    /// @notice Returns the index of the k-th and (k+1)-th largest elements in
    /// the array
    /// @param array Array in which k-th and (k+1)-th largest elements will be
    /// searched
    /// @param k K
    /// @return indK Index of the k-th largest element
    /// @return indKPlusOne Index of the (k+1)-th largest element
    function quickselectKPlusOne(
        int256[] memory array,
        uint256 k
    ) internal pure returns (uint256 indK, uint256 indKPlusOne) {
        uint256 arrayLength = array.length;
        assert(arrayLength > 1);
        unchecked {
            (indK, indKPlusOne) = quickselect(
                array,
                0,
                arrayLength - 1,
                k,
                true
            );
        }
    }

    /// @notice Returns the index of the k-th largest element in the specified
    /// section of the (potentially unsorted) array
    /// @param array Array in which K will be searched for
    /// @param lo Starting index of the section of the array that K will be
    /// searched in
    /// @param hi Last index of the section of the array that K will be
    /// searched in
    /// @param k K
    /// @param selectKPlusOne If the index of the (k+1)-th largest element is
    /// to be returned
    /// @return indK Index of the k-th largest element
    /// @return indKPlusOne Index of the (k+1)-th largest element (only set if
    /// `selectKPlusOne` is `true`)
    function quickselect(
        int256[] memory array,
        uint256 lo,
        uint256 hi,
        uint256 k,
        bool selectKPlusOne
    ) private pure returns (uint256 indK, uint256 indKPlusOne) {
        if (lo == hi) {
            return (k, 0);
        }
        uint256 indPivot = partition(array, lo, hi);
        if (k < indPivot) {
            unchecked {
                (indK, ) = quickselect(array, lo, indPivot - 1, k, false);
            }
        } else if (k > indPivot) {
            unchecked {
                (indK, ) = quickselect(array, indPivot + 1, hi, k, false);
            }
        } else {
            indK = indPivot;
        }
        // Since Quickselect ends in the array being partitioned around the
        // k-th largest element, we can continue searching towards right for
        // the (k+1)-th largest element, which is useful in calculating the
        // median of an array with even length
        if (selectKPlusOne) {
            unchecked {
                indKPlusOne = indK + 1;
            }
            uint256 i;
            unchecked {
                i = indKPlusOne + 1;
            }
            uint256 arrayLength = array.length;
            for (; i < arrayLength; ) {
                if (array[i] < array[indKPlusOne]) {
                    indKPlusOne = i;
                }
                unchecked {
                    i++;
                }
            }
        }
    }

    /// @notice Partitions the array into two around a pivot
    /// @param array Array that will be partitioned
    /// @param lo Starting index of the section of the array that will be
    /// partitioned
    /// @param hi Last index of the section of the array that will be
    /// partitioned
    /// @return pivotInd Pivot index
    function partition(
        int256[] memory array,
        uint256 lo,
        uint256 hi
    ) private pure returns (uint256 pivotInd) {
        if (lo == hi) {
            return lo;
        }
        int256 pivot = array[lo];
        uint256 i = lo;
        unchecked {
            pivotInd = hi + 1;
        }
        while (true) {
            do {
                unchecked {
                    i++;
                }
            } while (i < array.length && array[i] < pivot);
            do {
                unchecked {
                    pivotInd--;
                }
            } while (array[pivotInd] > pivot);
            if (i >= pivotInd) {
                (array[lo], array[pivotInd]) = (array[pivotInd], array[lo]);
                return pivotInd;
            }
            (array[i], array[pivotInd]) = (array[pivotInd], array[i]);
        }
    }
}

File 10 of 30 : Sort.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Contract to be inherited by contracts that will sort an array using
/// an unrolled implementation
/// @notice The operation will be in-place, i.e., the array provided as the
/// argument will be modified.
contract Sort {
    uint256 internal constant MAX_SORT_LENGTH = 9;

    /// @notice Sorts the array
    /// @param array Array to be sorted
    function sort(int256[] memory array) internal pure {
        uint256 arrayLength = array.length;
        require(arrayLength <= MAX_SORT_LENGTH, "Array too long to sort");
        // Do a binary search
        if (arrayLength < 6) {
            // Possible lengths: 1, 2, 3, 4, 5
            if (arrayLength < 4) {
                // Possible lengths: 1, 2, 3
                if (arrayLength == 3) {
                    // Length: 3
                    swapIfFirstIsLarger(array, 0, 1);
                    swapIfFirstIsLarger(array, 1, 2);
                    swapIfFirstIsLarger(array, 0, 1);
                } else if (arrayLength == 2) {
                    // Length: 2
                    swapIfFirstIsLarger(array, 0, 1);
                }
                // Do nothing for Length: 1
            } else {
                // Possible lengths: 4, 5
                if (arrayLength == 5) {
                    // Length: 5
                    swapIfFirstIsLarger(array, 1, 2);
                    swapIfFirstIsLarger(array, 3, 4);
                    swapIfFirstIsLarger(array, 1, 3);
                    swapIfFirstIsLarger(array, 0, 2);
                    swapIfFirstIsLarger(array, 2, 4);
                    swapIfFirstIsLarger(array, 0, 3);
                    swapIfFirstIsLarger(array, 0, 1);
                    swapIfFirstIsLarger(array, 2, 3);
                    swapIfFirstIsLarger(array, 1, 2);
                } else {
                    // Length: 4
                    swapIfFirstIsLarger(array, 0, 1);
                    swapIfFirstIsLarger(array, 2, 3);
                    swapIfFirstIsLarger(array, 1, 3);
                    swapIfFirstIsLarger(array, 0, 2);
                    swapIfFirstIsLarger(array, 1, 2);
                }
            }
        } else {
            // Possible lengths: 6, 7, 8, 9
            if (arrayLength < 8) {
                // Possible lengths: 6, 7
                if (arrayLength == 7) {
                    // Length: 7
                    swapIfFirstIsLarger(array, 1, 2);
                    swapIfFirstIsLarger(array, 3, 4);
                    swapIfFirstIsLarger(array, 5, 6);
                    swapIfFirstIsLarger(array, 0, 2);
                    swapIfFirstIsLarger(array, 4, 6);
                    swapIfFirstIsLarger(array, 3, 5);
                    swapIfFirstIsLarger(array, 2, 6);
                    swapIfFirstIsLarger(array, 1, 5);
                    swapIfFirstIsLarger(array, 0, 4);
                    swapIfFirstIsLarger(array, 2, 5);
                    swapIfFirstIsLarger(array, 0, 3);
                    swapIfFirstIsLarger(array, 2, 4);
                    swapIfFirstIsLarger(array, 1, 3);
                    swapIfFirstIsLarger(array, 0, 1);
                    swapIfFirstIsLarger(array, 2, 3);
                    swapIfFirstIsLarger(array, 4, 5);
                } else {
                    // Length: 6
                    swapIfFirstIsLarger(array, 0, 1);
                    swapIfFirstIsLarger(array, 2, 3);
                    swapIfFirstIsLarger(array, 4, 5);
                    swapIfFirstIsLarger(array, 1, 3);
                    swapIfFirstIsLarger(array, 3, 5);
                    swapIfFirstIsLarger(array, 1, 3);
                    swapIfFirstIsLarger(array, 2, 4);
                    swapIfFirstIsLarger(array, 0, 2);
                    swapIfFirstIsLarger(array, 2, 4);
                    swapIfFirstIsLarger(array, 3, 4);
                    swapIfFirstIsLarger(array, 1, 2);
                    swapIfFirstIsLarger(array, 2, 3);
                }
            } else {
                // Possible lengths: 8, 9
                if (arrayLength == 9) {
                    // Length: 9
                    swapIfFirstIsLarger(array, 1, 8);
                    swapIfFirstIsLarger(array, 2, 7);
                    swapIfFirstIsLarger(array, 3, 6);
                    swapIfFirstIsLarger(array, 4, 5);
                    swapIfFirstIsLarger(array, 1, 4);
                    swapIfFirstIsLarger(array, 5, 8);
                    swapIfFirstIsLarger(array, 0, 2);
                    swapIfFirstIsLarger(array, 6, 7);
                    swapIfFirstIsLarger(array, 2, 6);
                    swapIfFirstIsLarger(array, 7, 8);
                    swapIfFirstIsLarger(array, 0, 3);
                    swapIfFirstIsLarger(array, 4, 5);
                    swapIfFirstIsLarger(array, 0, 1);
                    swapIfFirstIsLarger(array, 3, 5);
                    swapIfFirstIsLarger(array, 6, 7);
                    swapIfFirstIsLarger(array, 2, 4);
                    swapIfFirstIsLarger(array, 1, 3);
                    swapIfFirstIsLarger(array, 5, 7);
                    swapIfFirstIsLarger(array, 4, 6);
                    swapIfFirstIsLarger(array, 1, 2);
                    swapIfFirstIsLarger(array, 3, 4);
                    swapIfFirstIsLarger(array, 5, 6);
                    swapIfFirstIsLarger(array, 7, 8);
                    swapIfFirstIsLarger(array, 2, 3);
                    swapIfFirstIsLarger(array, 4, 5);
                } else {
                    // Length: 8
                    swapIfFirstIsLarger(array, 0, 7);
                    swapIfFirstIsLarger(array, 1, 6);
                    swapIfFirstIsLarger(array, 2, 5);
                    swapIfFirstIsLarger(array, 3, 4);
                    swapIfFirstIsLarger(array, 0, 3);
                    swapIfFirstIsLarger(array, 4, 7);
                    swapIfFirstIsLarger(array, 1, 2);
                    swapIfFirstIsLarger(array, 5, 6);
                    swapIfFirstIsLarger(array, 0, 1);
                    swapIfFirstIsLarger(array, 2, 3);
                    swapIfFirstIsLarger(array, 4, 5);
                    swapIfFirstIsLarger(array, 6, 7);
                    swapIfFirstIsLarger(array, 3, 5);
                    swapIfFirstIsLarger(array, 2, 4);
                    swapIfFirstIsLarger(array, 1, 2);
                    swapIfFirstIsLarger(array, 3, 4);
                    swapIfFirstIsLarger(array, 5, 6);
                    swapIfFirstIsLarger(array, 2, 3);
                    swapIfFirstIsLarger(array, 4, 5);
                    swapIfFirstIsLarger(array, 3, 4);
                }
            }
        }
    }

    /// @notice Swaps two elements of an array if the first element is greater
    /// than the second
    /// @param array Array whose elements are to be swapped
    /// @param ind1 Index of the first element
    /// @param ind2 Index of the second element
    function swapIfFirstIsLarger(
        int256[] memory array,
        uint256 ind1,
        uint256 ind2
    ) private pure {
        if (array[ind1] > array[ind2]) {
            (array[ind1], array[ind2]) = (array[ind2], array[ind1]);
        }
    }
}

File 11 of 30 : BeaconUpdatesWithSignedData.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "./DataFeedServer.sol";
import "./interfaces/IBeaconUpdatesWithSignedData.sol";
import "../vendor/@openzeppelin/[email protected]/utils/cryptography/ECDSA.sol";

/// @title Contract that updates Beacons using signed data
contract BeaconUpdatesWithSignedData is
    DataFeedServer,
    IBeaconUpdatesWithSignedData
{
    using ECDSA for bytes32;

    /// @notice Updates a Beacon using data signed by the Airnode
    /// @dev The signed data here is intentionally very general for practical
    /// reasons. It is less demanding on the signer to have data signed once
    /// and use that everywhere.
    /// @param airnode Airnode address
    /// @param templateId Template ID
    /// @param timestamp Signature timestamp
    /// @param data Update data (an `int256` encoded in contract ABI)
    /// @param signature Template ID, timestamp and the update data signed by
    /// the Airnode
    /// @return beaconId Updated Beacon ID
    function updateBeaconWithSignedData(
        address airnode,
        bytes32 templateId,
        uint256 timestamp,
        bytes calldata data,
        bytes calldata signature
    ) external override returns (bytes32 beaconId) {
        require(
            (
                keccak256(abi.encodePacked(templateId, timestamp, data))
                    .toEthSignedMessageHash()
            ).recover(signature) == airnode,
            "Signature mismatch"
        );
        beaconId = deriveBeaconId(airnode, templateId);
        int224 updatedValue = processBeaconUpdate(beaconId, timestamp, data);
        emit UpdatedBeaconWithSignedData(
            beaconId,
            updatedValue,
            uint32(timestamp)
        );
    }
}

File 12 of 30 : DapiServer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "../access/AccessControlRegistryAdminnedWithManager.sol";
import "./DataFeedServer.sol";
import "./interfaces/IDapiServer.sol";

/// @title Contract that serves dAPIs mapped to Beacons and Beacon sets
/// @notice Beacons and Beacon sets are addressed by immutable IDs. Although
/// this is trust-minimized, it requires users to manage the ID of the data
/// feed they are using. For when the user does not want to do this, dAPIs can
/// be used as an abstraction layer. By using a dAPI, the user delegates this
/// responsibility to dAPI management. It is important for dAPI management to
/// be restricted by consensus rules (by using a multisig or a DAO) and similar
/// trustless security mechanisms.
contract DapiServer is
    AccessControlRegistryAdminnedWithManager,
    DataFeedServer,
    IDapiServer
{
    /// @notice dAPI name setter role description
    string public constant override DAPI_NAME_SETTER_ROLE_DESCRIPTION =
        "dAPI name setter";

    /// @notice dAPI name setter role
    bytes32 public immutable override dapiNameSetterRole;

    /// @notice dAPI name hash mapped to the data feed ID
    mapping(bytes32 => bytes32) public override dapiNameHashToDataFeedId;

    /// @param _accessControlRegistry AccessControlRegistry contract address
    /// @param _adminRoleDescription Admin role description
    /// @param _manager Manager address
    constructor(
        address _accessControlRegistry,
        string memory _adminRoleDescription,
        address _manager
    )
        AccessControlRegistryAdminnedWithManager(
            _accessControlRegistry,
            _adminRoleDescription,
            _manager
        )
    {
        dapiNameSetterRole = _deriveRole(
            _deriveAdminRole(manager),
            DAPI_NAME_SETTER_ROLE_DESCRIPTION
        );
    }

    /// @notice Sets the data feed ID the dAPI name points to
    /// @dev While a data feed ID refers to a specific Beacon or Beacon set,
    /// dAPI names provide a more abstract interface for convenience. This
    /// means a dAPI name that was pointing to a Beacon can be pointed to a
    /// Beacon set, then another Beacon set, etc.
    /// @param dapiName Human-readable dAPI name
    /// @param dataFeedId Data feed ID the dAPI name will point to
    function setDapiName(
        bytes32 dapiName,
        bytes32 dataFeedId
    ) external override {
        require(dapiName != bytes32(0), "dAPI name zero");
        require(
            msg.sender == manager ||
                IAccessControlRegistry(accessControlRegistry).hasRole(
                    dapiNameSetterRole,
                    msg.sender
                ),
            "Sender cannot set dAPI name"
        );
        dapiNameHashToDataFeedId[
            keccak256(abi.encodePacked(dapiName))
        ] = dataFeedId;
        emit SetDapiName(dataFeedId, dapiName, msg.sender);
    }

    /// @notice Returns the data feed ID the dAPI name is set to
    /// @param dapiName dAPI name
    /// @return Data feed ID
    function dapiNameToDataFeedId(
        bytes32 dapiName
    ) external view override returns (bytes32) {
        return dapiNameHashToDataFeedId[keccak256(abi.encodePacked(dapiName))];
    }

    /// @notice Reads the data feed with dAPI name hash
    /// @param dapiNameHash dAPI name hash
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function _readDataFeedWithDapiNameHash(
        bytes32 dapiNameHash
    ) internal view returns (int224 value, uint32 timestamp) {
        bytes32 dataFeedId = dapiNameHashToDataFeedId[dapiNameHash];
        require(dataFeedId != bytes32(0), "dAPI name not set");
        DataFeed storage dataFeed = _dataFeeds[dataFeedId];
        (value, timestamp) = (dataFeed.value, dataFeed.timestamp);
        require(timestamp > 0, "Data feed not initialized");
    }
}

File 13 of 30 : DataFeedServer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "../utils/ExtendedSelfMulticall.sol";
import "./aggregation/Median.sol";
import "./interfaces/IDataFeedServer.sol";
import "../vendor/@openzeppelin/[email protected]/utils/cryptography/ECDSA.sol";

/// @title Contract that serves Beacons and Beacon sets
/// @notice A Beacon is a live data feed addressed by an ID, which is derived
/// from an Airnode address and a template ID. This is suitable where the more
/// recent data point is always more favorable, e.g., in the context of an
/// asset price data feed. Beacons can also be seen as one-Airnode data feeds
/// that can be used individually or combined to build Beacon sets.
contract DataFeedServer is ExtendedSelfMulticall, Median, IDataFeedServer {
    using ECDSA for bytes32;

    // Airnodes serve their fulfillment data along with timestamps. This
    // contract casts the reported data to `int224` and the timestamp to
    // `uint32`, which works until year 2106.
    struct DataFeed {
        int224 value;
        uint32 timestamp;
    }

    /// @notice Data feed with ID
    mapping(bytes32 => DataFeed) internal _dataFeeds;

    /// @dev Reverts if the timestamp is from more than 1 hour in the future
    modifier onlyValidTimestamp(uint256 timestamp) virtual {
        unchecked {
            require(
                timestamp < block.timestamp + 1 hours,
                "Timestamp not valid"
            );
        }
        _;
    }

    /// @notice Updates the Beacon set using the current values of its Beacons
    /// @dev As an oddity, this function still works if some of the IDs in
    /// `beaconIds` belong to Beacon sets rather than Beacons. This can be used
    /// to implement hierarchical Beacon sets.
    /// @param beaconIds Beacon IDs
    /// @return beaconSetId Beacon set ID
    function updateBeaconSetWithBeacons(
        bytes32[] memory beaconIds
    ) public override returns (bytes32 beaconSetId) {
        (int224 updatedValue, uint32 updatedTimestamp) = aggregateBeacons(
            beaconIds
        );
        beaconSetId = deriveBeaconSetId(beaconIds);
        DataFeed storage beaconSet = _dataFeeds[beaconSetId];
        if (beaconSet.timestamp == updatedTimestamp) {
            require(
                beaconSet.value != updatedValue,
                "Does not update Beacon set"
            );
        }
        _dataFeeds[beaconSetId] = DataFeed({
            value: updatedValue,
            timestamp: updatedTimestamp
        });
        emit UpdatedBeaconSetWithBeacons(
            beaconSetId,
            updatedValue,
            updatedTimestamp
        );
    }

    /// @notice Reads the data feed with ID
    /// @param dataFeedId Data feed ID
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function _readDataFeedWithId(
        bytes32 dataFeedId
    ) internal view returns (int224 value, uint32 timestamp) {
        DataFeed storage dataFeed = _dataFeeds[dataFeedId];
        (value, timestamp) = (dataFeed.value, dataFeed.timestamp);
        require(timestamp > 0, "Data feed not initialized");
    }

    /// @notice Derives the Beacon ID from the Airnode address and template ID
    /// @param airnode Airnode address
    /// @param templateId Template ID
    /// @return beaconId Beacon ID
    function deriveBeaconId(
        address airnode,
        bytes32 templateId
    ) internal pure returns (bytes32 beaconId) {
        beaconId = keccak256(abi.encodePacked(airnode, templateId));
    }

    /// @notice Derives the Beacon set ID from the Beacon IDs
    /// @dev Notice that `abi.encode()` is used over `abi.encodePacked()`
    /// @param beaconIds Beacon IDs
    /// @return beaconSetId Beacon set ID
    function deriveBeaconSetId(
        bytes32[] memory beaconIds
    ) internal pure returns (bytes32 beaconSetId) {
        beaconSetId = keccak256(abi.encode(beaconIds));
    }

    /// @notice Called privately to process the Beacon update
    /// @param beaconId Beacon ID
    /// @param timestamp Timestamp used in the signature
    /// @param data Fulfillment data (an `int256` encoded in contract ABI)
    /// @return updatedBeaconValue Updated Beacon value
    function processBeaconUpdate(
        bytes32 beaconId,
        uint256 timestamp,
        bytes calldata data
    )
        internal
        onlyValidTimestamp(timestamp)
        returns (int224 updatedBeaconValue)
    {
        updatedBeaconValue = decodeFulfillmentData(data);
        require(
            timestamp > _dataFeeds[beaconId].timestamp,
            "Does not update timestamp"
        );
        _dataFeeds[beaconId] = DataFeed({
            value: updatedBeaconValue,
            timestamp: uint32(timestamp)
        });
    }

    /// @notice Called privately to decode the fulfillment data
    /// @param data Fulfillment data (an `int256` encoded in contract ABI)
    /// @return decodedData Decoded fulfillment data
    function decodeFulfillmentData(
        bytes memory data
    ) internal pure returns (int224) {
        require(data.length == 32, "Data length not correct");
        int256 decodedData = abi.decode(data, (int256));
        require(
            decodedData >= type(int224).min && decodedData <= type(int224).max,
            "Value typecasting error"
        );
        return int224(decodedData);
    }

    /// @notice Called privately to aggregate the Beacons and return the result
    /// @param beaconIds Beacon IDs
    /// @return value Aggregation value
    /// @return timestamp Aggregation timestamp
    function aggregateBeacons(
        bytes32[] memory beaconIds
    ) internal view returns (int224 value, uint32 timestamp) {
        uint256 beaconCount = beaconIds.length;
        require(beaconCount > 1, "Specified less than two Beacons");
        int256[] memory values = new int256[](beaconCount);
        int256[] memory timestamps = new int256[](beaconCount);
        for (uint256 ind = 0; ind < beaconCount; ) {
            DataFeed storage dataFeed = _dataFeeds[beaconIds[ind]];
            values[ind] = dataFeed.value;
            timestamps[ind] = int256(uint256(dataFeed.timestamp));
            unchecked {
                ind++;
            }
        }
        value = int224(median(values));
        timestamp = uint32(uint256(median(timestamps)));
    }
}

File 14 of 30 : 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);
}

File 15 of 30 : 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);
}

File 16 of 30 : IDapiServer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../../access/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);
}

File 17 of 30 : 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);
}

File 18 of 30 : IOevDapiServer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

interface IOevDapiServer is IOevDataFeedServer, IDapiServer {}

File 19 of 30 : 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);
}

File 20 of 30 : OevDapiServer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "./OevDataFeedServer.sol";
import "./DapiServer.sol";
import "./interfaces/IOevDapiServer.sol";

/// @title Contract that serves OEV dAPIs
contract OevDapiServer is OevDataFeedServer, DapiServer, IOevDapiServer {
    /// @param _accessControlRegistry AccessControlRegistry contract address
    /// @param _adminRoleDescription Admin role description
    /// @param _manager Manager address
    constructor(
        address _accessControlRegistry,
        string memory _adminRoleDescription,
        address _manager
    ) DapiServer(_accessControlRegistry, _adminRoleDescription, _manager) {}

    /// @notice Reads the data feed as the OEV proxy with dAPI name hash
    /// @param dapiNameHash dAPI name hash
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function _readDataFeedWithDapiNameHashAsOevProxy(
        bytes32 dapiNameHash
    ) internal view returns (int224 value, uint32 timestamp) {
        bytes32 dataFeedId = dapiNameHashToDataFeedId[dapiNameHash];
        require(dataFeedId != bytes32(0), "dAPI name not set");
        DataFeed storage oevDataFeed = _oevProxyToIdToDataFeed[msg.sender][
            dataFeedId
        ];
        DataFeed storage dataFeed = _dataFeeds[dataFeedId];
        if (oevDataFeed.timestamp > dataFeed.timestamp) {
            (value, timestamp) = (oevDataFeed.value, oevDataFeed.timestamp);
        } else {
            (value, timestamp) = (dataFeed.value, dataFeed.timestamp);
        }
        require(timestamp > 0, "Data feed not initialized");
    }
}

File 21 of 30 : OevDataFeedServer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "./DataFeedServer.sol";
import "./interfaces/IOevDataFeedServer.sol";
import "../vendor/@openzeppelin/[email protected]/utils/cryptography/ECDSA.sol";
import "./proxies/interfaces/IOevProxy.sol";

/// @title Contract that serves OEV Beacons and Beacon sets
/// @notice OEV Beacons and Beacon sets can be updated by the winner of the
/// respective OEV auctions. The beneficiary can withdraw the proceeds from
/// this contract.
contract OevDataFeedServer is DataFeedServer, IOevDataFeedServer {
    using ECDSA for bytes32;

    /// @notice Data feed with ID specific to the OEV proxy
    /// @dev This implies that an update as a result of an OEV auction only
    /// affects contracts that read through the respective proxy that the
    /// auction was being held for
    mapping(address => mapping(bytes32 => DataFeed))
        internal _oevProxyToIdToDataFeed;

    /// @notice Accumulated OEV auction proceeds for the specific proxy
    mapping(address => uint256) public override oevProxyToBalance;

    /// @notice Updates a data feed that the OEV proxy reads using the
    /// aggregation signed by the absolute majority of the respective Airnodes
    /// for the specific bid
    /// @dev For when the data feed being updated is a Beacon set, an absolute
    /// majority of the Airnodes that power the respective Beacons must sign
    /// the aggregated value and timestamp. While doing so, the Airnodes should
    /// refer to data signed to update an absolute majority of the respective
    /// Beacons. The Airnodes should require the data to be fresh enough (e.g.,
    /// at most 2 minutes-old), and tightly distributed around the resulting
    /// aggregation (e.g., within 1% deviation), and reject to provide an OEV
    /// proxy data feed update signature if these are not satisfied.
    /// @param oevProxy OEV proxy that reads the data feed
    /// @param dataFeedId Data feed ID
    /// @param updateId Update ID
    /// @param timestamp Signature timestamp
    /// @param data Update data (an `int256` encoded in contract ABI)
    /// @param packedOevUpdateSignatures Packed OEV update signatures, which
    /// include the Airnode address, template ID and these signed with the OEV
    /// update hash
    function updateOevProxyDataFeedWithSignedData(
        address oevProxy,
        bytes32 dataFeedId,
        bytes32 updateId,
        uint256 timestamp,
        bytes calldata data,
        bytes[] calldata packedOevUpdateSignatures
    ) external payable override onlyValidTimestamp(timestamp) {
        require(
            timestamp > _oevProxyToIdToDataFeed[oevProxy][dataFeedId].timestamp,
            "Does not update timestamp"
        );
        bytes32 oevUpdateHash = keccak256(
            abi.encodePacked(
                block.chainid,
                address(this),
                oevProxy,
                dataFeedId,
                updateId,
                timestamp,
                data,
                msg.sender,
                msg.value
            )
        );
        int224 updatedValue = decodeFulfillmentData(data);
        uint32 updatedTimestamp = uint32(timestamp);
        uint256 beaconCount = packedOevUpdateSignatures.length;
        if (beaconCount > 1) {
            bytes32[] memory beaconIds = new bytes32[](beaconCount);
            uint256 validSignatureCount;
            for (uint256 ind = 0; ind < beaconCount; ) {
                bool signatureIsNotOmitted;
                (
                    signatureIsNotOmitted,
                    beaconIds[ind]
                ) = unpackAndValidateOevUpdateSignature(
                    oevUpdateHash,
                    packedOevUpdateSignatures[ind]
                );
                if (signatureIsNotOmitted) {
                    unchecked {
                        validSignatureCount++;
                    }
                }
                unchecked {
                    ind++;
                }
            }
            // "Greater than or equal to" is not enough because full control
            // of aggregation requires an absolute majority
            require(
                validSignatureCount > beaconCount / 2,
                "Not enough signatures"
            );
            require(
                dataFeedId == deriveBeaconSetId(beaconIds),
                "Beacon set ID mismatch"
            );
            emit UpdatedOevProxyBeaconSetWithSignedData(
                dataFeedId,
                oevProxy,
                updateId,
                updatedValue,
                updatedTimestamp
            );
        } else if (beaconCount == 1) {
            {
                (
                    bool signatureIsNotOmitted,
                    bytes32 beaconId
                ) = unpackAndValidateOevUpdateSignature(
                        oevUpdateHash,
                        packedOevUpdateSignatures[0]
                    );
                require(signatureIsNotOmitted, "Missing signature");
                require(dataFeedId == beaconId, "Beacon ID mismatch");
            }
            emit UpdatedOevProxyBeaconWithSignedData(
                dataFeedId,
                oevProxy,
                updateId,
                updatedValue,
                updatedTimestamp
            );
        } else {
            revert("Did not specify any Beacons");
        }
        _oevProxyToIdToDataFeed[oevProxy][dataFeedId] = DataFeed({
            value: updatedValue,
            timestamp: updatedTimestamp
        });
        oevProxyToBalance[oevProxy] += msg.value;
    }

    /// @notice Withdraws the balance of the OEV proxy to the respective
    /// beneficiary account
    /// @dev This does not require the caller to be the beneficiary because we
    /// expect that in most cases, the OEV beneficiary will be a contract that
    /// will not be able to make arbitrary calls. Our choice can be worked
    /// around by implementing a beneficiary proxy.
    /// @param oevProxy OEV proxy
    function withdraw(address oevProxy) external override {
        address oevBeneficiary = IOevProxy(oevProxy).oevBeneficiary();
        require(oevBeneficiary != address(0), "Beneficiary address zero");
        uint256 balance = oevProxyToBalance[oevProxy];
        require(balance != 0, "OEV proxy balance zero");
        oevProxyToBalance[oevProxy] = 0;
        emit Withdrew(oevProxy, oevBeneficiary, balance);
        // solhint-disable-next-line avoid-low-level-calls
        (bool success, ) = oevBeneficiary.call{value: balance}("");
        require(success, "Withdrawal reverted");
    }

    /// @notice Reads the data feed as the OEV proxy with ID
    /// @param dataFeedId Data feed ID
    /// @return value Data feed value
    /// @return timestamp Data feed timestamp
    function _readDataFeedWithIdAsOevProxy(
        bytes32 dataFeedId
    ) internal view returns (int224 value, uint32 timestamp) {
        DataFeed storage oevDataFeed = _oevProxyToIdToDataFeed[msg.sender][
            dataFeedId
        ];
        DataFeed storage dataFeed = _dataFeeds[dataFeedId];
        if (oevDataFeed.timestamp > dataFeed.timestamp) {
            (value, timestamp) = (oevDataFeed.value, oevDataFeed.timestamp);
        } else {
            (value, timestamp) = (dataFeed.value, dataFeed.timestamp);
        }
        require(timestamp > 0, "Data feed not initialized");
    }

    /// @notice Called privately to unpack and validate the OEV update
    /// signature
    /// @param oevUpdateHash OEV update hash
    /// @param packedOevUpdateSignature Packed OEV update signature, which
    /// includes the Airnode address, template ID and these signed with the OEV
    /// update hash
    /// @return signatureIsNotOmitted If the signature is omitted in
    /// `packedOevUpdateSignature`
    /// @return beaconId Beacon ID
    function unpackAndValidateOevUpdateSignature(
        bytes32 oevUpdateHash,
        bytes calldata packedOevUpdateSignature
    ) private pure returns (bool signatureIsNotOmitted, bytes32 beaconId) {
        (address airnode, bytes32 templateId, bytes memory signature) = abi
            .decode(packedOevUpdateSignature, (address, bytes32, bytes));
        beaconId = deriveBeaconId(airnode, templateId);
        if (signature.length != 0) {
            require(
                (
                    keccak256(abi.encodePacked(oevUpdateHash, templateId))
                        .toEthSignedMessageHash()
                ).recover(signature) == airnode,
                "Signature mismatch"
            );
            signatureIsNotOmitted = true;
        }
    }
}

File 22 of 30 : IOevProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

File 23 of 30 : ExtendedSelfMulticall.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

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

/// @title Contract that extends SelfMulticall to fetch some of the global
/// variables
/// @notice Available global variables are limited to the ones that Airnode
/// tends to need
contract ExtendedSelfMulticall is SelfMulticall, IExtendedSelfMulticall {
    /// @notice Returns the chain ID
    /// @return Chain ID
    function getChainId() external view override returns (uint256) {
        return block.chainid;
    }

    /// @notice Returns the account balance
    /// @param account Account address
    /// @return Account balance
    function getBalance(
        address account
    ) external view override returns (uint256) {
        return account.balance;
    }

    /// @notice Returns if the account contains bytecode
    /// @dev An account not containing any bytecode does not indicate that it
    /// is an EOA or it will not contain any bytecode in the future.
    /// Contract construction and `SELFDESTRUCT` updates the bytecode at the
    /// end of the transaction.
    /// @return If the account contains bytecode
    function containsBytecode(
        address account
    ) external view override returns (bool) {
        return account.code.length > 0;
    }

    /// @notice Returns the current block number
    /// @return Current block number
    function getBlockNumber() external view override returns (uint256) {
        return block.number;
    }

    /// @notice Returns the current block timestamp
    /// @return Current block timestamp
    function getBlockTimestamp() external view override returns (uint256) {
        return block.timestamp;
    }

    /// @notice Returns the current block basefee
    /// @return Current block basefee
    function getBlockBasefee() external view override returns (uint256) {
        return block.basefee;
    }
}

File 24 of 30 : 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);
}

File 25 of 30 : 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);
}

File 26 of 30 : SelfMulticall.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./interfaces/ISelfMulticall.sol";

/// @title Contract that enables calls to the inheriting contract to be batched
/// @notice Implements two ways of batching, one requires none of the calls to
/// revert and the other tolerates individual calls reverting
/// @dev This implementation uses delegatecall for individual function calls.
/// Since delegatecall is a message call, it can only be made to functions that
/// are externally visible. This means that a contract cannot multicall its own
/// functions that use internal/private visibility modifiers.
/// Refer to OpenZeppelin's Multicall.sol for a similar implementation.
contract SelfMulticall is ISelfMulticall {
    /// @notice Batches calls to the inheriting contract and reverts as soon as
    /// one of the batched calls reverts
    /// @param data Array of calldata of batched calls
    /// @return returndata Array of returndata of batched calls
    function multicall(
        bytes[] calldata data
    ) external override returns (bytes[] memory returndata) {
        uint256 callCount = data.length;
        returndata = new bytes[](callCount);
        for (uint256 ind = 0; ind < callCount; ) {
            bool success;
            // solhint-disable-next-line avoid-low-level-calls
            (success, returndata[ind]) = address(this).delegatecall(data[ind]);
            if (!success) {
                bytes memory returndataWithRevertData = returndata[ind];
                if (returndataWithRevertData.length > 0) {
                    // Adapted from OpenZeppelin's Address.sol
                    // solhint-disable-next-line no-inline-assembly
                    assembly {
                        let returndata_size := mload(returndataWithRevertData)
                        revert(
                            add(32, returndataWithRevertData),
                            returndata_size
                        )
                    }
                } else {
                    revert("Multicall: No revert string");
                }
            }
            unchecked {
                ind++;
            }
        }
    }

    /// @notice Batches calls to the inheriting contract but does not revert if
    /// any of the batched calls reverts
    /// @param data Array of calldata of batched calls
    /// @return successes Array of success conditions of batched calls
    /// @return returndata Array of returndata of batched calls
    function tryMulticall(
        bytes[] calldata data
    )
        external
        override
        returns (bool[] memory successes, bytes[] memory returndata)
    {
        uint256 callCount = data.length;
        successes = new bool[](callCount);
        returndata = new bytes[](callCount);
        for (uint256 ind = 0; ind < callCount; ) {
            // solhint-disable-next-line avoid-low-level-calls
            (successes[ind], returndata[ind]) = address(this).delegatecall(
                data[ind]
            );
            unchecked {
                ind++;
            }
        }
    }
}

File 27 of 30 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 28 of 30 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 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));
    }
}

File 29 of 30 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 30 of 30 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_accessControlRegistry","type":"address"},{"internalType":"string","name":"_adminRoleDescription","type":"string"},{"internalType":"address","name":"_manager","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"dataFeedId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"dapiName","type":"bytes32"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"SetDapiName","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"beaconSetId","type":"bytes32"},{"indexed":false,"internalType":"int224","name":"value","type":"int224"},{"indexed":false,"internalType":"uint32","name":"timestamp","type":"uint32"}],"name":"UpdatedBeaconSetWithBeacons","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"beaconId","type":"bytes32"},{"indexed":false,"internalType":"int224","name":"value","type":"int224"},{"indexed":false,"internalType":"uint32","name":"timestamp","type":"uint32"}],"name":"UpdatedBeaconWithSignedData","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"beaconSetId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"proxy","type":"address"},{"indexed":true,"internalType":"bytes32","name":"updateId","type":"bytes32"},{"indexed":false,"internalType":"int224","name":"value","type":"int224"},{"indexed":false,"internalType":"uint32","name":"timestamp","type":"uint32"}],"name":"UpdatedOevProxyBeaconSetWithSignedData","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"beaconId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"proxy","type":"address"},{"indexed":true,"internalType":"bytes32","name":"updateId","type":"bytes32"},{"indexed":false,"internalType":"int224","name":"value","type":"int224"},{"indexed":false,"internalType":"uint32","name":"timestamp","type":"uint32"}],"name":"UpdatedOevProxyBeaconWithSignedData","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oevProxy","type":"address"},{"indexed":false,"internalType":"address","name":"oevBeneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrew","type":"event"},{"inputs":[],"name":"DAPI_NAME_SETTER_ROLE_DESCRIPTION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accessControlRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminRoleDescription","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"containsBytecode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"dapiNameHashToDataFeedId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dapiNameSetterRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dapiName","type":"bytes32"}],"name":"dapiNameToDataFeedId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"dataFeeds","outputs":[{"internalType":"int224","name":"value","type":"int224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockBasefee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"returndata","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"oevProxyToBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxy","type":"address"},{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"oevProxyToIdToDataFeed","outputs":[{"internalType":"int224","name":"value","type":"int224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dapiNameHash","type":"bytes32"}],"name":"readDataFeedWithDapiNameHash","outputs":[{"internalType":"int224","name":"value","type":"int224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dapiNameHash","type":"bytes32"}],"name":"readDataFeedWithDapiNameHashAsOevProxy","outputs":[{"internalType":"int224","name":"value","type":"int224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"readDataFeedWithId","outputs":[{"internalType":"int224","name":"value","type":"int224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"readDataFeedWithIdAsOevProxy","outputs":[{"internalType":"int224","name":"value","type":"int224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dapiName","type":"bytes32"},{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"setDapiName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"tryMulticall","outputs":[{"internalType":"bool[]","name":"successes","type":"bool[]"},{"internalType":"bytes[]","name":"returndata","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"beaconIds","type":"bytes32[]"}],"name":"updateBeaconSetWithBeacons","outputs":[{"internalType":"bytes32","name":"beaconSetId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"airnode","type":"address"},{"internalType":"bytes32","name":"templateId","type":"bytes32"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"updateBeaconWithSignedData","outputs":[{"internalType":"bytes32","name":"beaconId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"oevProxy","type":"address"},{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"},{"internalType":"bytes32","name":"updateId","type":"bytes32"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes[]","name":"packedOevUpdateSignatures","type":"bytes[]"}],"name":"updateOevProxyDataFeedWithSignedData","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"oevProxy","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x6080604052600436106101b55760003560e01c806367a7cfb7116100ec578063ac9650d81161008a578063e6ec76ac11610064578063e6ec76ac14610594578063f83ea108146105a7578063f8b2cb4f146105fe578063fce90be81461062657600080fd5b8063ac9650d814610527578063b62408a314610554578063cfaf49711461057457600080fd5b80638e6ddc27116100c65780638e6ddc271461049a5780638fca9ab9146104c757806391eed085146104e7578063a5fc076f1461050757600080fd5b806367a7cfb7146104125780637512449b14610453578063796b89b91461048757600080fd5b8063437b9116116101595780634c8f1d8d116101335780634c8f1d8d146103815780634dcc19fe146103a357806351cff8d9146103b65780635989eaeb146103d857600080fd5b8063437b9116146102f2578063472c22f114610320578063481c6a751461034d57600080fd5b80631ce9ae07116101955780631ce9ae071461024157806332be8f0b1461028d5780633408e470146102cc57806342cbb15c146102df57600080fd5b80629f2f3c146101ba578062aae33f146102015780631a0a0b3e14610221575b600080fd5b3480156101c657600080fd5b506101ee7f314d8b6c5739534f8cb6693b0b596897a37f836248b1921e4d8ce40e321f95aa81565b6040519081526020015b60405180910390f35b34801561020d57600080fd5b506101ee61021c366004612c34565b61066f565b34801561022d57600080fd5b506101ee61023c366004612d31565b61079c565b34801561024d57600080fd5b506102757f000000000000000000000000cd7df573b0f0bb4f2f8dfff6650cde8c7743173081565b6040516001600160a01b0390911681526020016101f8565b34801561029957600080fd5b506102ad6102a8366004612dc7565b610915565b60408051601b9390930b835263ffffffff9091166020830152016101f8565b3480156102d857600080fd5b50466101ee565b3480156102eb57600080fd5b50436101ee565b3480156102fe57600080fd5b5061031261030d366004612e25565b61092a565b6040516101f8929190612ef6565b34801561032c57600080fd5b506101ee61033b366004612dc7565b60046020526000908152604090205481565b34801561035957600080fd5b506102757f00000000000000000000000081bc85f329cdb28936fbb239f734ae495121f9a681565b34801561038d57600080fd5b50610396610a90565b6040516101f89190612f4f565b3480156103af57600080fd5b50486101ee565b3480156103c257600080fd5b506103d66103d1366004612f62565b610b1e565b005b3480156103e457600080fd5b506104026103f3366004612f62565b6001600160a01b03163b151590565b60405190151581526020016101f8565b34801561041e57600080fd5b506102ad61042d366004612dc7565b600090815260016020526040902054601b81900b91600160e01b90910463ffffffff1690565b34801561045f57600080fd5b506101ee7f506652eb0b4224e045c54db6ba6c475a8391491caaeb28361d1ef847fb66fdc181565b34801561049357600080fd5b50426101ee565b3480156104a657600080fd5b506101ee6104b5366004612f62565b60036020526000908152604090205481565b3480156104d357600080fd5b506101ee6104e2366004612dc7565b610d45565b3480156104f357600080fd5b506103d6610502366004612f7f565b610d8a565b34801561051357600080fd5b506102ad610522366004612dc7565b610f96565b34801561053357600080fd5b50610547610542366004612e25565b610fa2565b6040516101f89190612fa1565b34801561056057600080fd5b506102ad61056f366004612dc7565b611123565b34801561058057600080fd5b506102ad61058f366004612dc7565b61112f565b6103d66105a2366004612fb4565b61113b565b3480156105b357600080fd5b506102ad6105c2366004613053565b6001600160a01b039190911660009081526002602090815260408083209383529290522054601b81900b91600160e01b90910463ffffffff1690565b34801561060a57600080fd5b506101ee610619366004612f62565b6001600160a01b03163190565b34801561063257600080fd5b506103966040518060400160405280601081526020017f64415049206e616d65207365747465720000000000000000000000000000000081525081565b600080600061067d846116c2565b9150915061068a84611864565b600081815260016020526040902080549194509063ffffffff808416600160e01b9092041603610710578054601b84810b91900b036107105760405162461bcd60e51b815260206004820152601a60248201527f446f6573206e6f742075706461746520426561636f6e2073657400000000000060448201526064015b60405180910390fd5b604080518082018252601b85900b80825263ffffffff858116602080850182815260008b81526001835287902095519051909316600160e01b026001600160e01b0390931692909217909355835191825281019190915285917fb7712be6248d021e8c56ac9613c09491354a4d0f4ad0b7db1a664b35be4b2349910160405180910390a2505050919050565b6000876001600160a01b031661081d84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505060405161081792506107fc91508c908c908c908c9060200161307f565b60405160208183030381529060405280519060200120611894565b906118cf565b6001600160a01b0316146108735760405162461bcd60e51b815260206004820152601260248201527f5369676e6174757265206d69736d6174636800000000000000000000000000006044820152606401610707565b50604080516bffffffffffffffffffffffff1960608a901b1660208083019190915260348083018a9052835180840390910181526054909201909252805191012060006108c2828888886118f5565b60408051601b83900b815263ffffffff8a16602082015291925083917f1ffdb573afe7273932e253bc4b8a17b9da4d37d7219ba05e464358975b36efb7910160405180910390a250979650505050505050565b60008061092183611a4a565b91509150915091565b606080828067ffffffffffffffff81111561094757610947612bed565b604051908082528060200260200182016040528015610970578160200160208202803683370190505b5092508067ffffffffffffffff81111561098c5761098c612bed565b6040519080825280602002602001820160405280156109bf57816020015b60608152602001906001900390816109aa5790505b50915060005b81811015610a8757308686838181106109e0576109e06130a0565b90506020028101906109f291906130b6565b604051610a009291906130fd565b600060405180830381855af49150503d8060008114610a3b576040519150601f19603f3d011682016040523d82523d6000602084013e610a40565b606091505b50858381518110610a5357610a536130a0565b60200260200101858481518110610a6c57610a6c6130a0565b602090810291909101019190915290151590526001016109c5565b50509250929050565b60008054610a9d9061310d565b80601f0160208091040260200160405190810160405280929190818152602001828054610ac99061310d565b8015610b165780601f10610aeb57610100808354040283529160200191610b16565b820191906000526020600020905b815481529060010190602001808311610af957829003601f168201915b505050505081565b6000816001600160a01b0316630e15999d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b829190613141565b90506001600160a01b038116610bda5760405162461bcd60e51b815260206004820152601860248201527f42656e65666963696172792061646472657373207a65726f00000000000000006044820152606401610707565b6001600160a01b03821660009081526003602052604081205490819003610c435760405162461bcd60e51b815260206004820152601660248201527f4f45562070726f78792062616c616e6365207a65726f000000000000000000006044820152606401610707565b6001600160a01b0383811660008181526003602090815260408083209290925581519386168452830184905290917f0472be967f9a37138dfea1875af44784cafb79f92044ab33d7d6958eddd9ca6c910160405180910390a26000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610ce9576040519150601f19603f3d011682016040523d82523d6000602084013e610cee565b606091505b5050905080610d3f5760405162461bcd60e51b815260206004820152601360248201527f5769746864726177616c207265766572746564000000000000000000000000006044820152606401610707565b50505050565b60006004600083604051602001610d5e91815260200190565b604051602081830303815290604052805190602001208152602001908152602001600020549050919050565b81610dd75760405162461bcd60e51b815260206004820152600e60248201527f64415049206e616d65207a65726f0000000000000000000000000000000000006044820152606401610707565b336001600160a01b037f00000000000000000000000081bc85f329cdb28936fbb239f734ae495121f9a6161480610ed057506040517f91d148540000000000000000000000000000000000000000000000000000000081527f506652eb0b4224e045c54db6ba6c475a8391491caaeb28361d1ef847fb66fdc160048201523360248201527f000000000000000000000000cd7df573b0f0bb4f2f8dfff6650cde8c774317306001600160a01b0316906391d1485490604401602060405180830381865afa158015610eac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed0919061315e565b610f1c5760405162461bcd60e51b815260206004820152601b60248201527f53656e6465722063616e6e6f74207365742064415049206e616d6500000000006044820152606401610707565b806004600084604051602001610f3491815260200190565b60408051601f1981840301815291815281516020928301208352828201939093529082016000209290925551338152839183917ff3a9aac9b6ac0f842cb5d9b3491cd5fc1b6a6778d97fd9529f587339865294f5910160405180910390a35050565b60008061092183611b7d565b6060818067ffffffffffffffff811115610fbe57610fbe612bed565b604051908082528060200260200182016040528015610ff157816020015b6060815260200190600190039081610fdc5790505b50915060005b8181101561111b57600030868684818110611014576110146130a0565b905060200281019061102691906130b6565b6040516110349291906130fd565b600060405180830381855af49150503d806000811461106f576040519150601f19603f3d011682016040523d82523d6000602084013e611074565b606091505b50858481518110611087576110876130a0565b60209081029190910101529050806111125760008483815181106110ad576110ad6130a0565b602002602001015190506000815111156110ca5780518082602001fd5b60405162461bcd60e51b815260206004820152601b60248201527f4d756c746963616c6c3a204e6f2072657665727420737472696e6700000000006044820152606401610707565b50600101610ff7565b505092915050565b60008061092183611bf5565b60008061092183611ccd565b8442610e1001811061118f5760405162461bcd60e51b815260206004820152601360248201527f54696d657374616d70206e6f742076616c6964000000000000000000000000006044820152606401610707565b6001600160a01b03891660009081526002602090815260408083208b8452909152902054600160e01b900463ffffffff16861161120e5760405162461bcd60e51b815260206004820152601960248201527f446f6573206e6f74207570646174652074696d657374616d70000000000000006044820152606401610707565b600046308b8b8b8b8b8b33346040516020016112339a99989796959493929190613180565b604051602081830303815290604052805190602001209050600061128c87878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d9f92505050565b9050878460018111156114615760008167ffffffffffffffff8111156112b4576112b4612bed565b6040519080825280602002602001820160405280156112dd578160200160208202803683370190505b5090506000805b8381101561135057600061131b888c8c85818110611304576113046130a0565b905060200281019061131691906130b6565b611ea2565b85848151811061132d5761132d6130a0565b602090810291909101015290508015611347576001909201915b506001016112e4565b5061135c6002846131ff565b81116113aa5760405162461bcd60e51b815260206004820152601560248201527f4e6f7420656e6f756768207369676e61747572657300000000000000000000006044820152606401610707565b6113b382611864565b8e146114015760405162461bcd60e51b815260206004820152601660248201527f426561636f6e20736574204944206d69736d61746368000000000000000000006044820152606401610707565b8c8f6001600160a01b03168f7fdd29860e0772a39dea2ff0520d79f8efdffe48c903d6bbbc0c2cc65dc6568a7f8888604051611452929190601b9290920b825263ffffffff16602082015260400190565b60405180910390a450506115cb565b8060010361158357600080611483868a8a6000818110611304576113046130a0565b91509150816114d45760405162461bcd60e51b815260206004820152601160248201527f4d697373696e67207369676e61747572650000000000000000000000000000006044820152606401610707565b808e146115235760405162461bcd60e51b815260206004820152601260248201527f426561636f6e204944206d69736d6174636800000000000000000000000000006044820152606401610707565b50508a8d6001600160a01b03168d7fc856aaa4e639403f366ad68f07eb69bad4c044a35b0369c4ef1ea3a427a6a0ee8686604051611576929190601b9290920b825263ffffffff16602082015260400190565b60405180910390a46115cb565b60405162461bcd60e51b815260206004820152601b60248201527f446964206e6f74207370656369667920616e7920426561636f6e7300000000006044820152606401610707565b604051806040016040528084601b0b81526020018363ffffffff16815250600260008f6001600160a01b03166001600160a01b0316815260200190815260200160002060008e815260200190815260200160002060008201518160000160006101000a8154816001600160e01b030219169083601b0b6001600160e01b03160217905550602082015181600001601c6101000a81548163ffffffff021916908363ffffffff16021790555090505034600360008f6001600160a01b03166001600160a01b0316815260200190815260200160002060008282546116ae9190613213565b909155505050505050505050505050505050565b80516000908190600181116117195760405162461bcd60e51b815260206004820152601f60248201527f537065636966696564206c657373207468616e2074776f20426561636f6e73006044820152606401610707565b60008167ffffffffffffffff81111561173457611734612bed565b60405190808252806020026020018201604052801561175d578160200160208202803683370190505b50905060008267ffffffffffffffff81111561177b5761177b612bed565b6040519080825280602002602001820160405280156117a4578160200160208202803683370190505b50905060005b83811015611845576000600160008984815181106117ca576117ca6130a0565b602090810291909101810151825281019190915260400160002080548551919250601b0b90859084908110611801576118016130a0565b602090810291909101015280548351600160e01b90910463ffffffff1690849084908110611831576118316130a0565b6020908102919091010152506001016117aa565b5061184f82611fa4565b945061185a81611fa4565b9350505050915091565b6000816040516020016118779190613234565b604051602081830303815290604052805190602001209050919050565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01611877565b60008060006118de85856120fd565b915091506118eb81612142565b5090505b92915050565b60008342610e1001811061194b5760405162461bcd60e51b815260206004820152601360248201527f54696d657374616d70206e6f742076616c6964000000000000000000000000006044820152606401610707565b61198a84848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d9f92505050565b600087815260016020526040902054909250600160e01b900463ffffffff1685116119f75760405162461bcd60e51b815260206004820152601960248201527f446f6573206e6f74207570646174652074696d657374616d70000000000000006044820152606401610707565b50604080518082018252601b83900b815263ffffffff95861660208083019182526000988952600190529190962095519051909416600160e01b026001600160e01b039094169390931790935550919050565b600081815260046020526040812054819080611aa85760405162461bcd60e51b815260206004820152601160248201527f64415049206e616d65206e6f74207365740000000000000000000000000000006044820152606401610707565b336000908152600260209081526040808320848452825280832060019092529091208054825463ffffffff600160e01b92839004811692909104161115611b06578154601b81900b9550600160e01b900463ffffffff169350611b1f565b8054601b81900b9550600160e01b900463ffffffff1693505b60008463ffffffff1611611b755760405162461bcd60e51b815260206004820152601960248201527f446174612066656564206e6f7420696e697469616c697a6564000000000000006044820152606401610707565b505050915091565b60008181526001602052604090208054601b81900b91600160e01b90910463ffffffff169081611bef5760405162461bcd60e51b815260206004820152601960248201527f446174612066656564206e6f7420696e697469616c697a6564000000000000006044820152606401610707565b50915091565b600081815260046020526040812054819080611c535760405162461bcd60e51b815260206004820152601160248201527f64415049206e616d65206e6f74207365740000000000000000000000000000006044820152606401610707565b60008181526001602052604090208054601b81900b9450600160e01b900463ffffffff16925082611cc65760405162461bcd60e51b815260206004820152601960248201527f446174612066656564206e6f7420696e697469616c697a6564000000000000006044820152606401610707565b5050915091565b336000908152600260209081526040808320848452825280832060019092528220805482548493929163ffffffff600160e01b918290048116919092049091161115611d30578154601b81900b9450600160e01b900463ffffffff169250611d49565b8054601b81900b9450600160e01b900463ffffffff1692505b60008363ffffffff1611611cc65760405162461bcd60e51b815260206004820152601960248201527f446174612066656564206e6f7420696e697469616c697a6564000000000000006044820152606401610707565b60008151602014611df25760405162461bcd60e51b815260206004820152601760248201527f44617461206c656e677468206e6f7420636f72726563740000000000000000006044820152606401610707565b600082806020019051810190611e089190613278565b90507fffffffff800000000000000000000000000000000000000000000000000000008112801590611e5657507b7fffffffffffffffffffffffffffffffffffffffffffffffffffffff8113155b6118ef5760405162461bcd60e51b815260206004820152601760248201527f56616c7565207479706563617374696e67206572726f720000000000000000006044820152606401610707565b600080808080611eb486880188613291565b925092509250611f0683836040516bffffffffffffffffffffffff19606084901b1660208201526034810182905260009060540160405160208183030381529060405280519060200120905092915050565b93508051600014611f9957826001600160a01b0316611f3e826108178b866040516020016107fc929190918252602082015260400190565b6001600160a01b031614611f945760405162461bcd60e51b815260206004820152601260248201527f5369676e6174757265206d69736d6174636800000000000000000000000000006044820152606401610707565b600194505b505050935093915050565b80516000906009811161207d57611fba836122aa565b611fc5600282613342565b600103611ff85782611fd86002836131ff565b81518110611fe857611fe86130a0565b6020026020010151915050919050565b8060000361200857612008613356565b612076836001600284040381518110612023576120236130a0565b6020026020010151846002848161203c5761203c6131e9565b048151811061204d5761204d6130a0565b6020026020010151600182811d82821d01838316919091160160ff81901c838318160192915050565b9392505050565b612088600282613342565b6001036120a45782611fd88161209f6002856131ff565b6127bc565b6000806120b785600160028604036127e9565b80925081935050506120ee8583815181106120d4576120d46130a0565b602002602001015186838151811061204d5761204d6130a0565b95945050505050565b50919050565b60008082516041036121335760208301516040840151606085015160001a6121278782858561281e565b9450945050505061213b565b506000905060025b9250929050565b60008160048111156121565761215661336c565b0361215e5750565b60018160048111156121725761217261336c565b036121bf5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610707565b60028160048111156121d3576121d361336c565b036122205760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610707565b60038160048111156122345761223461336c565b036122a75760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610707565b50565b805160098111156122fd5760405162461bcd60e51b815260206004820152601660248201527f417272617920746f6f206c6f6e6720746f20736f7274000000000000000000006044820152606401610707565b600681101561240857600481101561235757806003036123425761232482600060016128e2565b61233182600160026128e2565b61233e82600060016128e2565b5050565b8060020361233e5761233e82600060016128e2565b806005036123d45761236c82600160026128e2565b61237982600360046128e2565b61238682600160036128e2565b61239382600060026128e2565b6123a082600260046128e2565b6123ad82600060036128e2565b6123ba82600060016128e2565b6123c782600260036128e2565b61233e82600160026128e2565b6123e182600060016128e2565b6123ee82600260036128e2565b6123fb82600160036128e2565b6123c782600060026128e2565b600881101561258557806007036124e95761242682600160026128e2565b61243382600360046128e2565b61244082600560066128e2565b61244d82600060026128e2565b61245a82600460066128e2565b61246782600360056128e2565b61247482600260066128e2565b61248182600160056128e2565b61248e82600060046128e2565b61249b82600260056128e2565b6124a882600060036128e2565b6124b582600260046128e2565b6124c282600160036128e2565b6124cf82600060016128e2565b6124dc82600260036128e2565b61233e82600460056128e2565b6124f682600060016128e2565b61250382600260036128e2565b61251082600460056128e2565b61251d82600160036128e2565b61252a82600360056128e2565b61253782600160036128e2565b61254482600260046128e2565b61255182600060026128e2565b61255e82600260046128e2565b61256b82600360046128e2565b61257882600160026128e2565b61233e82600260036128e2565b806009036126b85761259a82600160086128e2565b6125a782600260076128e2565b6125b482600360066128e2565b6125c182600460056128e2565b6125ce82600160046128e2565b6125db82600560086128e2565b6125e882600060026128e2565b6125f582600660076128e2565b61260282600260066128e2565b61260f82600760086128e2565b61261c82600060036128e2565b61262982600460056128e2565b61263682600060016128e2565b61264382600360056128e2565b61265082600660076128e2565b61265d82600260046128e2565b61266a82600160036128e2565b61267782600560076128e2565b61268482600460066128e2565b61269182600160026128e2565b61269e82600360046128e2565b6126ab82600560066128e2565b6124cf82600760086128e2565b6126c582600060076128e2565b6126d282600160066128e2565b6126df82600260056128e2565b6126ec82600360046128e2565b6126f982600060036128e2565b61270682600460076128e2565b61271382600160026128e2565b61272082600560066128e2565b61272d82600060016128e2565b61273a82600260036128e2565b61274782600460056128e2565b61275482600660076128e2565b61276182600360056128e2565b61276e82600260046128e2565b61277b82600160026128e2565b61278882600360046128e2565b61279582600560066128e2565b6127a282600260036128e2565b6127af82600460056128e2565b61233e82600360046128e2565b8151600090806127ce576127ce613356565b6127e084600060018403866000612990565b50949350505050565b815160009081906001811161280057612800613356565b61281285600060018403876001612990565b90969095509350505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561285557506000905060036128d9565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156128a9573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166128d2576000600192509250506128d9565b9150600090505b94509492505050565b8281815181106128f4576128f46130a0565b602002602001015183838151811061290e5761290e6130a0565b6020026020010151131561298b5782818151811061292e5761292e6130a0565b6020026020010151838381518110612948576129486130a0565b6020026020010151848481518110612962576129626130a0565b6020026020010185848151811061297b5761297b6130a0565b6020908102919091010191909152525b505050565b6000808486036129a557508290506000612a5c565b60006129b2888888612a66565b9050808510156129d5576129cd888860018403886000612990565b5092506129f2565b808511156129ee576129cd888260010188886000612990565b8092505b8315612a5a57875160018401925060028401905b80821015612a5757898481518110612a2057612a206130a0565b60200260200101518a8381518110612a3a57612a3a6130a0565b60200260200101511215612a4c578193505b600190910190612a06565b50505b505b9550959350505050565b6000818303612a76575081612076565b6000848481518110612a8a57612a8a6130a0565b6020026020010151905060008490508360010192505b855160019091019081108015612ace575081868281518110612ac457612ac46130a0565b6020026020010151125b612aa0575b82806001900393505081868481518110612aef57612aef6130a0565b602002602001015113612ad357828110612b7a57858381518110612b1557612b156130a0565b6020026020010151868681518110612b2f57612b2f6130a0565b6020026020010151878781518110612b4957612b496130a0565b60200260200101888681518110612b6257612b626130a0565b60200260200101828152508281525050505050612076565b858381518110612b8c57612b8c6130a0565b6020026020010151868281518110612ba657612ba66130a0565b6020026020010151878381518110612bc057612bc06130a0565b60200260200101888681518110612bd957612bd96130a0565b602090810291909101019190915252612aa0565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612c2c57612c2c612bed565b604052919050565b60006020808385031215612c4757600080fd5b823567ffffffffffffffff80821115612c5f57600080fd5b818501915085601f830112612c7357600080fd5b813581811115612c8557612c85612bed565b8060051b9150612c96848301612c03565b8181529183018401918481019088841115612cb057600080fd5b938501935b83851015612cce57843582529385019390850190612cb5565b98975050505050505050565b6001600160a01b03811681146122a757600080fd5b60008083601f840112612d0157600080fd5b50813567ffffffffffffffff811115612d1957600080fd5b60208301915083602082850101111561213b57600080fd5b600080600080600080600060a0888a031215612d4c57600080fd5b8735612d5781612cda565b96506020880135955060408801359450606088013567ffffffffffffffff80821115612d8257600080fd5b612d8e8b838c01612cef565b909650945060808a0135915080821115612da757600080fd5b50612db48a828b01612cef565b989b979a50959850939692959293505050565b600060208284031215612dd957600080fd5b5035919050565b60008083601f840112612df257600080fd5b50813567ffffffffffffffff811115612e0a57600080fd5b6020830191508360208260051b850101111561213b57600080fd5b60008060208385031215612e3857600080fd5b823567ffffffffffffffff811115612e4f57600080fd5b61281285828601612de0565b6000815180845260005b81811015612e8157602081850181015186830182015201612e65565b506000602082860101526020601f19601f83011685010191505092915050565b600081518084526020808501808196508360051b8101915082860160005b85811015612ee9578284038952612ed7848351612e5b565b98850198935090840190600101612ebf565b5091979650505050505050565b604080825283519082018190526000906020906060840190828701845b82811015612f31578151151584529284019290840190600101612f13565b50505083810382850152612f458186612ea1565b9695505050505050565b6020815260006120766020830184612e5b565b600060208284031215612f7457600080fd5b813561207681612cda565b60008060408385031215612f9257600080fd5b50508035926020909101359150565b6020815260006120766020830184612ea1565b60008060008060008060008060c0898b031215612fd057600080fd5b8835612fdb81612cda565b9750602089013596506040890135955060608901359450608089013567ffffffffffffffff8082111561300d57600080fd5b6130198c838d01612cef565b909650945060a08b013591508082111561303257600080fd5b5061303f8b828c01612de0565b999c989b5096995094979396929594505050565b6000806040838503121561306657600080fd5b823561307181612cda565b946020939093013593505050565b84815283602082015281836040830137600091016040019081529392505050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126130cd57600080fd5b83018035915067ffffffffffffffff8211156130e857600080fd5b60200191503681900382131561213b57600080fd5b8183823760009101908152919050565b600181811c9082168061312157607f821691505b6020821081036120f757634e487b7160e01b600052602260045260246000fd5b60006020828403121561315357600080fd5b815161207681612cda565b60006020828403121561317057600080fd5b8151801515811461207657600080fd5b8a815260006bffffffffffffffffffffffff19808c60601b166020840152808b60601b166034840152896048840152886068840152876088840152858760a885013760609490941b909316930160a881019390935260bc8301525060dc01979650505050505050565b634e487b7160e01b600052601260045260246000fd5b60008261320e5761320e6131e9565b500490565b808201808211156118ef57634e487b7160e01b600052601160045260246000fd5b6020808252825182820181905260009190848201906040850190845b8181101561326c57835183529284019291840191600101613250565b50909695505050505050565b60006020828403121561328a57600080fd5b5051919050565b6000806000606084860312156132a657600080fd5b83356132b181612cda565b92506020848101359250604085013567ffffffffffffffff808211156132d657600080fd5b818701915087601f8301126132ea57600080fd5b8135818111156132fc576132fc612bed565b61330e601f8201601f19168501612c03565b9150808252888482850101111561332457600080fd5b80848401858401376000848284010152508093505050509250925092565b600082613351576133516131e9565b500690565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052602160045260246000fdfea2646970667358221220693313c61a998d79d0e9b250367bd14ac439bd3d1d1f36bf50317fc99059456d64736f6c63430008110033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ 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.