ETH Price: $3,316.70 (-1.10%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Batch Report171018462023-04-22 12:20:59627 days ago1682166059IN
0x946c1CbD...7b19b63e2
0 ETH0.0123161335.42163101
Batch Report170947272023-04-21 12:20:23628 days ago1682079623IN
0x946c1CbD...7b19b63e2
0 ETH0.0068578731.75516687
Batch Report170876702023-04-20 12:20:59629 days ago1681993259IN
0x946c1CbD...7b19b63e2
0 ETH0.0141543556.78323849
Batch Report170806062023-04-19 12:20:23630 days ago1681906823IN
0x946c1CbD...7b19b63e2
0 ETH0.019178674.91114918
Batch Report170735292023-04-18 12:20:47631 days ago1681820447IN
0x946c1CbD...7b19b63e2
0 ETH0.009330643.20504045
Batch Report170664562023-04-17 12:20:23632 days ago1681734023IN
0x946c1CbD...7b19b63e2
0 ETH0.0058915827.28077819
Batch Report170594102023-04-16 12:20:47633 days ago1681647647IN
0x946c1CbD...7b19b63e2
0 ETH0.0055115625.52110252
Batch Report170523702023-04-15 12:20:23634 days ago1681561223IN
0x946c1CbD...7b19b63e2
0 ETH0.0059649623.2968134
Batch Report170453762023-04-14 12:20:47635 days ago1681474847IN
0x946c1CbD...7b19b63e2
0 ETH0.0061707728.57355378
Batch Report170385122023-04-13 12:21:11636 days ago1681388471IN
0x946c1CbD...7b19b63e2
0 ETH0.0135366430.71970952
Add Member169959382023-04-07 10:10:11642 days ago1680862211IN
0x946c1CbD...7b19b63e2
0 ETH0.002314320

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BeaconStakingOracle

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 9 : BeaconStakingOracle.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.6.10 <0.8.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/EnumerableSet.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import "../../utils/SafeDecimalMath.sol";
import "../../interfaces/IFundV3.sol";

interface IEthStakingStrategy {
    struct OperatorData {
        uint256 id;
        uint256 beaconBalance;
        uint256 validatorCount;
        uint256 executionLayerReward;
    }

    function fund() external view returns (address);

    function batchReport(
        uint256 epoch,
        OperatorData[] calldata operatorData,
        uint256 finalizationCount
    ) external;
}

contract BeaconStakingOracle is Ownable {
    using SafeMath for uint256;
    using SafeDecimalMath for uint256;
    using EnumerableSet for EnumerableSet.AddressSet;

    event BeaconReported(uint256 epochId, bytes32 report, address caller);
    event MemberAdded(address member);
    event MemberRemoved(address member);
    event AnnualMaxChangeUpdated(uint256 newAnnualMaxChange);
    event QuorumUpdated(uint256 newQuorum);

    IEthStakingStrategy public immutable strategy;
    IFundV3 public immutable fund;

    /// @notice Number of epochs between adjacent reports
    uint256 public immutable reportableEpochInterval;

    uint256 public immutable secondsPerEpoch;

    /// @notice Timestamp of epoch 0
    uint256 public immutable genesisTime;

    uint256 public annualMaxChange;

    /// @notice Number of exactly the same reports needed to finalize the epoch
    uint256 public quorum;
    uint256 public nonce;
    uint256 public lastCompletedEpoch;

    /// @notice Epoch => report hash => received count
    mapping(uint256 => mapping(bytes32 => uint256)) public reports;

    /// @dev Oracle member => epoch of the most recent report
    mapping(address => uint256) public lastReportedEpoch;

    EnumerableSet.AddressSet private _members;

    constructor(
        address strategy_,
        uint256 reportableEpochInterval_,
        uint256 secondsPerEpoch_,
        uint256 genesisTime_,
        uint256 annualMaxChange_
    ) public {
        strategy = IEthStakingStrategy(strategy_);
        fund = IFundV3(IEthStakingStrategy(strategy_).fund());
        reportableEpochInterval = reportableEpochInterval_;
        secondsPerEpoch = secondsPerEpoch_;
        require(genesisTime_ < block.timestamp);
        genesisTime = genesisTime_;
        _updateAnnualMaxChange(annualMaxChange_);
    }

    /// @notice Report validator balances on Beacon chain
    /// @param epoch Beacon chain epoch
    /// @param operatorData Per-operator report data including Node operator IDs, which must be sorted in ascending order
    /// @param finalizationCount Number of finalizable redemptions
    function batchReport(
        uint256 epoch,
        IEthStakingStrategy.OperatorData[] calldata operatorData,
        uint256 finalizationCount
    ) external onlyMember {
        require(
            epoch <= getLatestReportableEpoch() &&
                epoch > lastCompletedEpoch &&
                epoch % reportableEpochInterval == 0,
            "Invalid epoch"
        );
        require(lastReportedEpoch[msg.sender] < epoch, "Already reported");
        lastReportedEpoch[msg.sender] = epoch;

        // Push the result to `reports` queue, report to strategy if counts exceed `quorum`
        bytes32 report = encodeBatchReport(operatorData, finalizationCount);
        uint256 currentCount = reports[epoch][report] + 1;
        emit BeaconReported(epoch, report, msg.sender);

        if (currentCount >= quorum) {
            uint256 preTotalUnderlying = fund.getTotalUnderlying();
            uint256 preEquivalentTotalQ = fund.getEquivalentTotalQ();
            strategy.batchReport(epoch, operatorData, finalizationCount);
            uint256 postTotalUnderlying = fund.getTotalUnderlying();
            uint256 postEquivalentTotalQ = fund.getEquivalentTotalQ();

            uint256 timeElapsed = (epoch - lastCompletedEpoch) * secondsPerEpoch;
            _sanityCheck(
                postTotalUnderlying,
                postEquivalentTotalQ,
                preTotalUnderlying,
                preEquivalentTotalQ,
                timeElapsed
            );
            lastCompletedEpoch = epoch;

            if (currentCount > 1) {
                reports[epoch][report] = 0; // Clear storage for gas refund
            }
        } else {
            reports[epoch][report] = currentCount;
        }
    }

    /// @dev Performs logical consistency check of the underlying changes as the result of reports push
    function _sanityCheck(
        uint256 postTotalUnderlying,
        uint256 postEquivalentTotalQ,
        uint256 preTotalUnderlying,
        uint256 preEquivalentTotalQ,
        uint256 timeElapsed
    ) private view {
        if (postEquivalentTotalQ == 0 || preEquivalentTotalQ == 0) {
            return;
        }
        uint256 postNav = postTotalUnderlying.divideDecimal(postEquivalentTotalQ);
        uint256 preNav = preTotalUnderlying.divideDecimal(preEquivalentTotalQ);
        uint256 delta = postNav >= preNav ? postNav - preNav : preNav - postNav;
        require(
            delta.mul(365 days) / timeElapsed <= preNav.multiplyDecimal(annualMaxChange),
            "Annual max delta"
        );
    }

    /// @notice Return the latest reportable epoch
    function getLatestReportableEpoch() public view returns (uint256) {
        uint256 latestEpoch = (block.timestamp - genesisTime) / secondsPerEpoch;
        return (latestEpoch / reportableEpochInterval) * reportableEpochInterval;
    }

    function encodeBatchReport(
        IEthStakingStrategy.OperatorData[] calldata operatorData,
        uint256 finalizationCount
    ) public view returns (bytes32) {
        return keccak256(abi.encode(operatorData, finalizationCount, nonce));
    }

    /// @notice Return the epoch that an oracle member should report now,
    ///         or zero if the latest reportable epoch is already reported.
    function getNextEpochByMember(address member) external view returns (uint256) {
        uint256 epoch = getLatestReportableEpoch();
        uint256 last = lastReportedEpoch[member];
        return epoch > last ? epoch : 0;
    }

    modifier onlyMember() {
        require(_members.contains(msg.sender), "Member not found");
        _;
    }

    function getMemberCount() external view returns (uint256) {
        return _members.length();
    }

    function getMembers() external view returns (address[] memory members) {
        uint256 length = _members.length();
        members = new address[](length);
        for (uint256 i = 0; i < length; i++) {
            members[i] = _members.at(i);
        }
    }

    function addMember(address member, uint256 newQuorum) external onlyOwner {
        require(member != address(0), "Invalid address");
        require(!_members.contains(member), "Already a member");
        _members.add(member);
        emit MemberAdded(member);

        _updateQuorum(newQuorum);
    }

    function removeMember(address member, uint256 newQuorum) external onlyOwner {
        require(_members.contains(member), "Not a member");
        _members.remove(member);
        emit MemberRemoved(member);

        _updateQuorum(newQuorum);

        // Force out the previous records, and allow the remained oracles to report it again
        nonce++;
    }

    function updateAnnualMaxChange(uint256 newAnnualMaxChange) external onlyOwner {
        _updateAnnualMaxChange(newAnnualMaxChange);
    }

    function updateQuorum(uint256 newQuorum) external onlyOwner {
        _updateQuorum(newQuorum);
    }

    function _updateAnnualMaxChange(uint256 newAnnualMaxChange) private {
        annualMaxChange = newAnnualMaxChange;
        emit AnnualMaxChangeUpdated(newAnnualMaxChange);
    }

    function _updateQuorum(uint256 newQuorum) private {
        quorum = newQuorum;
        emit QuorumUpdated(newQuorum);
    }
}

File 2 of 9 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 3 of 9 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

File 4 of 9 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 5 of 9 : SafeDecimalMath.sol
// SPDX-License-Identifier: MIT
//
// Copyright (c) 2019 Synthetix
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
pragma solidity >=0.6.10 <0.8.0;

import "@openzeppelin/contracts/math/SafeMath.sol";

library SafeDecimalMath {
    using SafeMath for uint256;

    /* Number of decimal places in the representations. */
    uint256 private constant decimals = 18;
    uint256 private constant highPrecisionDecimals = 27;

    /* The number representing 1.0. */
    uint256 private constant UNIT = 10**uint256(decimals);

    /* The number representing 1.0 for higher fidelity numbers. */
    uint256 private constant PRECISE_UNIT = 10**uint256(highPrecisionDecimals);
    uint256 private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR =
        10**uint256(highPrecisionDecimals - decimals);

    /**
     * @return The result of multiplying x and y, interpreting the operands as fixed-point
     * decimals.
     *
     * @dev A unit factor is divided out after the product of x and y is evaluated,
     * so that product must be less than 2**256. As this is an integer division,
     * the internal division always rounds down. This helps save on gas. Rounding
     * is more expensive on gas.
     */
    function multiplyDecimal(uint256 x, uint256 y) internal pure returns (uint256) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        return x.mul(y).div(UNIT);
    }

    function multiplyDecimalPrecise(uint256 x, uint256 y) internal pure returns (uint256) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        return x.mul(y).div(PRECISE_UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is a high
     * precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and UNIT must be less than 2**256. As
     * this is an integer division, the result is always rounded down.
     * This helps save on gas. Rounding is more expensive on gas.
     */
    function divideDecimal(uint256 x, uint256 y) internal pure returns (uint256) {
        /* Reintroduce the UNIT factor that will be divided out by y. */
        return x.mul(UNIT).div(y);
    }

    function divideDecimalPrecise(uint256 x, uint256 y) internal pure returns (uint256) {
        /* Reintroduce the UNIT factor that will be divided out by y. */
        return x.mul(PRECISE_UNIT).div(y);
    }

    /**
     * @dev Convert a standard decimal representation to a high precision one.
     */
    function decimalToPreciseDecimal(uint256 i) internal pure returns (uint256) {
        return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
    }

    /**
     * @dev Convert a high precision decimal to a standard decimal representation.
     */
    function preciseDecimalToDecimal(uint256 i) internal pure returns (uint256) {
        uint256 quotientTimesTen = i.mul(10).div(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen = quotientTimesTen.add(10);
        }

        return quotientTimesTen.div(10);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, and the max value of
     * uint256 on overflow.
     */
    function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        return c / a != b ? type(uint256).max : c;
    }

    function saturatingMultiplyDecimal(uint256 x, uint256 y) internal pure returns (uint256) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        return saturatingMul(x, y).div(UNIT);
    }
}

File 6 of 9 : IFundV3.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.6.10 <0.8.0;
pragma experimental ABIEncoderV2;

import "./ITwapOracleV2.sol";

interface IFundV3 {
    /// @notice A linear transformation matrix that represents a rebalance.
    ///
    ///         ```
    ///             [        1        0        0 ]
    ///         R = [ ratioB2Q  ratioBR        0 ]
    ///             [ ratioR2Q        0  ratioBR ]
    ///         ```
    ///
    ///         Amounts of the three tranches `q`, `b` and `r` can be rebalanced by multiplying the matrix:
    ///
    ///         ```
    ///         [ q', b', r' ] = [ q, b, r ] * R
    ///         ```
    struct Rebalance {
        uint256 ratioB2Q;
        uint256 ratioR2Q;
        uint256 ratioBR;
        uint256 timestamp;
    }

    function tokenUnderlying() external view returns (address);

    function tokenQ() external view returns (address);

    function tokenB() external view returns (address);

    function tokenR() external view returns (address);

    function tokenShare(uint256 tranche) external view returns (address);

    function primaryMarket() external view returns (address);

    function primaryMarketUpdateProposal() external view returns (address, uint256);

    function strategy() external view returns (address);

    function strategyUpdateProposal() external view returns (address, uint256);

    function underlyingDecimalMultiplier() external view returns (uint256);

    function twapOracle() external view returns (ITwapOracleV2);

    function feeCollector() external view returns (address);

    function endOfDay(uint256 timestamp) external pure returns (uint256);

    function trancheTotalSupply(uint256 tranche) external view returns (uint256);

    function trancheBalanceOf(uint256 tranche, address account) external view returns (uint256);

    function trancheAllBalanceOf(address account)
        external
        view
        returns (
            uint256,
            uint256,
            uint256
        );

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

    function trancheAllowance(
        uint256 tranche,
        address owner,
        address spender
    ) external view returns (uint256);

    function trancheAllowanceVersion(address owner, address spender)
        external
        view
        returns (uint256);

    function trancheTransfer(
        uint256 tranche,
        address recipient,
        uint256 amount,
        uint256 version
    ) external;

    function trancheTransferFrom(
        uint256 tranche,
        address sender,
        address recipient,
        uint256 amount,
        uint256 version
    ) external;

    function trancheApprove(
        uint256 tranche,
        address spender,
        uint256 amount,
        uint256 version
    ) external;

    function getRebalanceSize() external view returns (uint256);

    function getRebalance(uint256 index) external view returns (Rebalance memory);

    function getRebalanceTimestamp(uint256 index) external view returns (uint256);

    function currentDay() external view returns (uint256);

    function splitRatio() external view returns (uint256);

    function historicalSplitRatio(uint256 version) external view returns (uint256);

    function fundActivityStartTime() external view returns (uint256);

    function isFundActive(uint256 timestamp) external view returns (bool);

    function getEquivalentTotalB() external view returns (uint256);

    function getEquivalentTotalQ() external view returns (uint256);

    function historicalEquivalentTotalB(uint256 timestamp) external view returns (uint256);

    function historicalNavs(uint256 timestamp) external view returns (uint256 navB, uint256 navR);

    function extrapolateNav(uint256 price)
        external
        view
        returns (
            uint256,
            uint256,
            uint256
        );

    function doRebalance(
        uint256 amountQ,
        uint256 amountB,
        uint256 amountR,
        uint256 index
    )
        external
        view
        returns (
            uint256 newAmountQ,
            uint256 newAmountB,
            uint256 newAmountR
        );

    function batchRebalance(
        uint256 amountQ,
        uint256 amountB,
        uint256 amountR,
        uint256 fromIndex,
        uint256 toIndex
    )
        external
        view
        returns (
            uint256 newAmountQ,
            uint256 newAmountB,
            uint256 newAmountR
        );

    function refreshBalance(address account, uint256 targetVersion) external;

    function refreshAllowance(
        address owner,
        address spender,
        uint256 targetVersion
    ) external;

    function shareTransfer(
        address sender,
        address recipient,
        uint256 amount
    ) external;

    function shareTransferFrom(
        address spender,
        address sender,
        address recipient,
        uint256 amount
    ) external returns (uint256 newAllowance);

    function shareIncreaseAllowance(
        address sender,
        address spender,
        uint256 addedValue
    ) external returns (uint256 newAllowance);

    function shareDecreaseAllowance(
        address sender,
        address spender,
        uint256 subtractedValue
    ) external returns (uint256 newAllowance);

    function shareApprove(
        address owner,
        address spender,
        uint256 amount
    ) external;

    function historicalUnderlying(uint256 timestamp) external view returns (uint256);

    function getTotalUnderlying() external view returns (uint256);

    function getStrategyUnderlying() external view returns (uint256);

    function getTotalDebt() external view returns (uint256);

    event RebalanceTriggered(
        uint256 indexed index,
        uint256 indexed day,
        uint256 navSum,
        uint256 navB,
        uint256 navROrZero,
        uint256 ratioB2Q,
        uint256 ratioR2Q,
        uint256 ratioBR
    );
    event Settled(uint256 indexed day, uint256 navB, uint256 navR, uint256 interestRate);
    event InterestRateUpdated(uint256 baseInterestRate, uint256 floatingInterestRate);
    event BalancesRebalanced(
        address indexed account,
        uint256 version,
        uint256 balanceQ,
        uint256 balanceB,
        uint256 balanceR
    );
    event AllowancesRebalanced(
        address indexed owner,
        address indexed spender,
        uint256 version,
        uint256 allowanceQ,
        uint256 allowanceB,
        uint256 allowanceR
    );
}

File 7 of 9 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 8 of 9 : ITwapOracleV2.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.6.10 <0.8.0;

import "./ITwapOracle.sol";

interface ITwapOracleV2 is ITwapOracle {
    function getLatest() external view returns (uint256);
}

File 9 of 9 : ITwapOracle.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.6.10 <0.8.0;

interface ITwapOracle {
    enum UpdateType {PRIMARY, SECONDARY, OWNER, CHAINLINK, UNISWAP_V2}

    function getTwap(uint256 timestamp) external view returns (uint256);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"strategy_","type":"address"},{"internalType":"uint256","name":"reportableEpochInterval_","type":"uint256"},{"internalType":"uint256","name":"secondsPerEpoch_","type":"uint256"},{"internalType":"uint256","name":"genesisTime_","type":"uint256"},{"internalType":"uint256","name":"annualMaxChange_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newAnnualMaxChange","type":"uint256"}],"name":"AnnualMaxChangeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epochId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"report","type":"bytes32"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"BeaconReported","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"member","type":"address"}],"name":"MemberAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"member","type":"address"}],"name":"MemberRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newQuorum","type":"uint256"}],"name":"QuorumUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"member","type":"address"},{"internalType":"uint256","name":"newQuorum","type":"uint256"}],"name":"addMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"annualMaxChange","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"beaconBalance","type":"uint256"},{"internalType":"uint256","name":"validatorCount","type":"uint256"},{"internalType":"uint256","name":"executionLayerReward","type":"uint256"}],"internalType":"struct IEthStakingStrategy.OperatorData[]","name":"operatorData","type":"tuple[]"},{"internalType":"uint256","name":"finalizationCount","type":"uint256"}],"name":"batchReport","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"beaconBalance","type":"uint256"},{"internalType":"uint256","name":"validatorCount","type":"uint256"},{"internalType":"uint256","name":"executionLayerReward","type":"uint256"}],"internalType":"struct IEthStakingStrategy.OperatorData[]","name":"operatorData","type":"tuple[]"},{"internalType":"uint256","name":"finalizationCount","type":"uint256"}],"name":"encodeBatchReport","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fund","outputs":[{"internalType":"contract IFundV3","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"genesisTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestReportableEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMembers","outputs":[{"internalType":"address[]","name":"members","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"getNextEpochByMember","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastCompletedEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastReportedEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quorum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"},{"internalType":"uint256","name":"newQuorum","type":"uint256"}],"name":"removeMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reportableEpochInterval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"reports","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"secondsPerEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategy","outputs":[{"internalType":"contract IEthStakingStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAnnualMaxChange","type":"uint256"}],"name":"updateAnnualMaxChange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newQuorum","type":"uint256"}],"name":"updateQuorum","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6101206040523480156200001257600080fd5b506040516200193e3803806200193e8339810160408190526200003591620001e9565b60006200004162000160565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350846001600160a01b03166080816001600160a01b031660601b81525050846001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b158015620000e257600080fd5b505afa158015620000f7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200011d9190620001c4565b60601b6001600160601b03191660a05260c084905260e08390524282106200014457600080fd5b610100829052620001558162000164565b50505050506200023c565b3390565b60018190556040517ff835e8dcf6b25346fd90f601a094c8c85d19413e1a94da9936c01137cc4942b0906200019b90839062000233565b60405180910390a150565b80516001600160a01b0381168114620001be57600080fd5b92915050565b600060208284031215620001d6578081fd5b620001e28383620001a6565b9392505050565b600080600080600060a0868803121562000201578081fd5b6200020d8787620001a6565b602087015160408801516060890151608090990151929a91995097965090945092505050565b90815260200190565b60805160601c60a05160601c60c05160e05161010051611685620002b9600039806103eb52806104f45250806103ca52806105185280610a535250806104185280610439528061067a5280610cb1525080610776528061080b528061092552806109ba5280610c8d5250806108b45280610c6352506116856000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c80638da5cb5b116100c3578063affed0e01161007c578063affed0e014610277578063b60d42881461027f578063b9f9e52d14610287578063ca1ee9671461028f578063f2fde38b14610297578063f940ea03146102aa57610158565b80638da5cb5b14610217578063935087551461022c57806398041ea31461023f578063997072f7146102525780639eab52531461025a578063a8c62e761461026f57610158565b806342c6498a1161011557806342c6498a146101d1578063580c8f3d146101d9578063715018a6146101e1578063726d3506146101e95780637d6e05a0146101fc57806381ddcd621461020f57610158565b806315f5b9231461015d57806316f6f03e146101865780631703a0181461019b578063186b8b8a146101a357806335680dc2146101ab5780633d36f808146101be575b600080fd5b61017061016b3660046111e1565b6102bd565b60405161017d91906113a9565b60405180910390f35b6101996101943660046111b7565b6102f7565b005b6101706103bf565b6101706103c5565b6101996101b936600461122b565b610468565b6101706101cc36600461119c565b6104b3565b6101706104f2565b610170610516565b61019961053a565b6101706101f736600461119c565b6105c3565b61019961020a36600461122b565b6105d5565b61017061061d565b61021f610623565b60405161017d9190611321565b61019961023a36600461125b565b610632565b61019961024d3660046111b7565b610ad8565b610170610bb5565b610262610bc6565b60405161017d9190611335565b61021f610c61565b610170610c85565b61021f610c8b565b610170610caf565b610170610cd3565b6101996102a536600461119c565b610cd9565b6101706102b83660046112ac565b610d99565b60008383836003546040516020016102d89493929190611382565b6040516020818303038152906040528051906020012090509392505050565b6102ff610db6565b6001600160a01b0316610310610623565b6001600160a01b03161461033f5760405162461bcd60e51b815260040161033690611555565b60405180910390fd5b61034a600783610dba565b6103665760405162461bcd60e51b8152600401610336906114ee565b610371600783610dd8565b507f6e76fb4c77256006d9c38ec7d82b45a8c8f3c27b1d6766fffc42dfb8de684492826040516103a19190611321565b60405180910390a16103b281610ded565b5050600380546001019055565b60025481565b6000807f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000042038161041357fe5b0490507f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000828161046057fe5b040291505090565b610470610db6565b6001600160a01b0316610481610623565b6001600160a01b0316146104a75760405162461bcd60e51b815260040161033690611555565b6104b081610ded565b50565b6000806104be6103c5565b6001600160a01b0384166000908152600660205260409020549091508082116104e85760006104ea565b815b949350505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b610542610db6565b6001600160a01b0316610553610623565b6001600160a01b0316146105795760405162461bcd60e51b815260040161033690611555565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60066020526000908152604090205481565b6105dd610db6565b6001600160a01b03166105ee610623565b6001600160a01b0316146106145760405162461bcd60e51b815260040161033690611555565b6104b081610e2d565b60015481565b6000546001600160a01b031690565b61063d600733610dba565b6106595760405162461bcd60e51b8152600401610336906115db565b6106616103c5565b8411158015610671575060045484115b80156106a457507f000000000000000000000000000000000000000000000000000000000000000084816106a157fe5b06155b6106c05760405162461bcd60e51b81526004016103369061158a565b3360009081526006602052604090205484116106ee5760405162461bcd60e51b815260040161033690611463565b33600090815260066020526040812085905561070b8484846102bd565b600086815260056020908152604080832084845290915290819020549051919250600101907f420414ff78f3fd2d51d111065ea2478754bd5f3eabded30d8c7ea0ce11e90e519061076190889085903390611630565b60405180910390a16002548110610ab35760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b40494e56040518163ffffffff1660e01b815260040160206040518083038186803b1580156107cd57600080fd5b505afa1580156107e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108059190611243565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166312e778b66040518163ffffffff1660e01b815260040160206040518083038186803b15801561086257600080fd5b505afa158015610876573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089a9190611243565b604051639350875560e01b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906393508755906108ef908b908b908b908b90600401611605565b600060405180830381600087803b15801561090957600080fd5b505af115801561091d573d6000803e3d6000fd5b5050505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b40494e56040518163ffffffff1660e01b815260040160206040518083038186803b15801561097c57600080fd5b505afa158015610990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b49190611243565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166312e778b66040518163ffffffff1660e01b815260040160206040518083038186803b158015610a1157600080fd5b505afa158015610a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a499190611243565b6004549091508a037f000000000000000000000000000000000000000000000000000000000000000002610a808383878785610e62565b60048b90556001861115610aa95760008b81526005602090815260408083208a84529091528120555b5050505050610ad0565b600086815260056020908152604080832085845290915290208190555b505050505050565b610ae0610db6565b6001600160a01b0316610af1610623565b6001600160a01b031614610b175760405162461bcd60e51b815260040161033690611555565b6001600160a01b038216610b3d5760405162461bcd60e51b8152600401610336906113f4565b610b48600783610dba565b15610b655760405162461bcd60e51b8152600401610336906115b1565b610b70600783610f00565b507fb251eb052afc73ffd02ffe85ad79990a8b3fed60d76dbc2fa2fdd7123dffd91482604051610ba09190611321565b60405180910390a1610bb181610ded565b5050565b6000610bc16007610f15565b905090565b60606000610bd46007610f15565b90508067ffffffffffffffff81118015610bed57600080fd5b50604051908082528060200260200182016040528015610c17578160200160208202803683370190505b50915060005b81811015610c5c57610c30600782610f20565b838281518110610c3c57fe5b6001600160a01b0390921660209283029190910190910152600101610c1d565b505090565b7f000000000000000000000000000000000000000000000000000000000000000081565b60035481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60045481565b610ce1610db6565b6001600160a01b0316610cf2610623565b6001600160a01b031614610d185760405162461bcd60e51b815260040161033690611555565b6001600160a01b038116610d3e5760405162461bcd60e51b81526004016103369061141d565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600560209081526000928352604080842090915290825290205481565b3390565b6000610dcf836001600160a01b038416610f2c565b90505b92915050565b6000610dcf836001600160a01b038416610f44565b60028190556040517ff18f88786aae85a652aadb99a82462616489a33370c9bcc7b245906812ef7cd190610e229083906113a9565b60405180910390a150565b60018190556040517ff835e8dcf6b25346fd90f601a094c8c85d19413e1a94da9936c01137cc4942b090610e229083906113a9565b831580610e6d575081155b15610e7757610ef9565b6000610e83868661100a565b90506000610e91858561100a565b9050600081831015610ea557828203610ea9565b8183035b9050610ec06001548361102890919063ffffffff16565b84610ecf836301e1338061103c565b81610ed657fe5b041115610ef55760405162461bcd60e51b81526004016103369061148d565b5050505b5050505050565b6000610dcf836001600160a01b038416611076565b6000610dd2826110c0565b6000610dcf83836110c4565b60009081526001919091016020526040902054151590565b600081815260018301602052604081205480156110005783546000198083019190810190600090879083908110610f7757fe5b9060005260206000200154905080876000018481548110610f9457fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080610fc457fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610dd2565b6000915050610dd2565b6000610dcf8261102285670de0b6b3a764000061103c565b90611109565b6000610dcf670de0b6b3a764000061102285855b60008261104b57506000610dd2565b8282028284828161105857fe5b0414610dcf5760405162461bcd60e51b815260040161033690611514565b60006110828383610f2c565b6110b857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610dd2565b506000610dd2565b5490565b815460009082106110e75760405162461bcd60e51b8152600401610336906113b2565b8260000182815481106110f657fe5b9060005260206000200154905092915050565b600080821161112a5760405162461bcd60e51b8152600401610336906114b7565b81838161113357fe5b049392505050565b80356001600160a01b0381168114610dd257600080fd5b60008083601f840112611163578182fd5b50813567ffffffffffffffff81111561117a578182fd5b60208301915083602060808302850101111561119557600080fd5b9250929050565b6000602082840312156111ad578081fd5b610dcf838361113b565b600080604083850312156111c9578081fd5b6111d3848461113b565b946020939093013593505050565b6000806000604084860312156111f5578081fd5b833567ffffffffffffffff81111561120b578182fd5b61121786828701611152565b909790965060209590950135949350505050565b60006020828403121561123c578081fd5b5035919050565b600060208284031215611254578081fd5b5051919050565b60008060008060608587031215611270578081fd5b84359350602085013567ffffffffffffffff81111561128d578182fd5b61129987828801611152565b9598909750949560400135949350505050565b600080604083850312156112be578182fd5b50508035926020909101359150565b60008284526020808501945082825b85811015611316578135875282820135838801526040808301359088015260608083013590880152608096870196909101906001016112dc565b509495945050505050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b818110156113765783516001600160a01b031683529284019291840191600101611351565b50909695505050505050565b6000606082526113966060830186886112cd565b6020830194909452506040015292915050565b90815260200190565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252600f908201526e496e76616c6964206164647265737360881b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526010908201526f105b1c9958591e481c995c1bdc9d195960821b604082015260600190565b60208082526010908201526f416e6e75616c206d61782064656c746160801b604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b6020808252600c908201526b2737ba10309036b2b6b132b960a11b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600d908201526c092dcecc2d8d2c840cae0dec6d609b1b604082015260600190565b60208082526010908201526f20b63932b0b23c90309036b2b6b132b960811b604082015260600190565b60208082526010908201526f13595b58995c881b9bdd08199bdd5b9960821b604082015260600190565b60008582526060602083015261161f6060830185876112cd565b905082604083015295945050505050565b92835260208301919091526001600160a01b031660408201526060019056fea2646970667358221220216c6bc760f91f507ebd9ab2df843ba314d3e81e9023e7eda2450d056127c09864736f6c634300060c003300000000000000000000000050fe5165be08095a1f4cd96877cc54b3cc2ea08e00000000000000000000000000000000000000000000000000000000000000e10000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000005fc630570000000000000000000000000000000000000000000000000429d069189e0000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101585760003560e01c80638da5cb5b116100c3578063affed0e01161007c578063affed0e014610277578063b60d42881461027f578063b9f9e52d14610287578063ca1ee9671461028f578063f2fde38b14610297578063f940ea03146102aa57610158565b80638da5cb5b14610217578063935087551461022c57806398041ea31461023f578063997072f7146102525780639eab52531461025a578063a8c62e761461026f57610158565b806342c6498a1161011557806342c6498a146101d1578063580c8f3d146101d9578063715018a6146101e1578063726d3506146101e95780637d6e05a0146101fc57806381ddcd621461020f57610158565b806315f5b9231461015d57806316f6f03e146101865780631703a0181461019b578063186b8b8a146101a357806335680dc2146101ab5780633d36f808146101be575b600080fd5b61017061016b3660046111e1565b6102bd565b60405161017d91906113a9565b60405180910390f35b6101996101943660046111b7565b6102f7565b005b6101706103bf565b6101706103c5565b6101996101b936600461122b565b610468565b6101706101cc36600461119c565b6104b3565b6101706104f2565b610170610516565b61019961053a565b6101706101f736600461119c565b6105c3565b61019961020a36600461122b565b6105d5565b61017061061d565b61021f610623565b60405161017d9190611321565b61019961023a36600461125b565b610632565b61019961024d3660046111b7565b610ad8565b610170610bb5565b610262610bc6565b60405161017d9190611335565b61021f610c61565b610170610c85565b61021f610c8b565b610170610caf565b610170610cd3565b6101996102a536600461119c565b610cd9565b6101706102b83660046112ac565b610d99565b60008383836003546040516020016102d89493929190611382565b6040516020818303038152906040528051906020012090509392505050565b6102ff610db6565b6001600160a01b0316610310610623565b6001600160a01b03161461033f5760405162461bcd60e51b815260040161033690611555565b60405180910390fd5b61034a600783610dba565b6103665760405162461bcd60e51b8152600401610336906114ee565b610371600783610dd8565b507f6e76fb4c77256006d9c38ec7d82b45a8c8f3c27b1d6766fffc42dfb8de684492826040516103a19190611321565b60405180910390a16103b281610ded565b5050600380546001019055565b60025481565b6000807f00000000000000000000000000000000000000000000000000000000000001807f000000000000000000000000000000000000000000000000000000005fc6305742038161041357fe5b0490507f00000000000000000000000000000000000000000000000000000000000000e17f00000000000000000000000000000000000000000000000000000000000000e1828161046057fe5b040291505090565b610470610db6565b6001600160a01b0316610481610623565b6001600160a01b0316146104a75760405162461bcd60e51b815260040161033690611555565b6104b081610ded565b50565b6000806104be6103c5565b6001600160a01b0384166000908152600660205260409020549091508082116104e85760006104ea565b815b949350505050565b7f000000000000000000000000000000000000000000000000000000005fc6305781565b7f000000000000000000000000000000000000000000000000000000000000018081565b610542610db6565b6001600160a01b0316610553610623565b6001600160a01b0316146105795760405162461bcd60e51b815260040161033690611555565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60066020526000908152604090205481565b6105dd610db6565b6001600160a01b03166105ee610623565b6001600160a01b0316146106145760405162461bcd60e51b815260040161033690611555565b6104b081610e2d565b60015481565b6000546001600160a01b031690565b61063d600733610dba565b6106595760405162461bcd60e51b8152600401610336906115db565b6106616103c5565b8411158015610671575060045484115b80156106a457507f00000000000000000000000000000000000000000000000000000000000000e184816106a157fe5b06155b6106c05760405162461bcd60e51b81526004016103369061158a565b3360009081526006602052604090205484116106ee5760405162461bcd60e51b815260040161033690611463565b33600090815260066020526040812085905561070b8484846102bd565b600086815260056020908152604080832084845290915290819020549051919250600101907f420414ff78f3fd2d51d111065ea2478754bd5f3eabded30d8c7ea0ce11e90e519061076190889085903390611630565b60405180910390a16002548110610ab35760007f00000000000000000000000069c53679ec1c06f3275b64c428e8cd069a2d39666001600160a01b031663b40494e56040518163ffffffff1660e01b815260040160206040518083038186803b1580156107cd57600080fd5b505afa1580156107e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108059190611243565b905060007f00000000000000000000000069c53679ec1c06f3275b64c428e8cd069a2d39666001600160a01b03166312e778b66040518163ffffffff1660e01b815260040160206040518083038186803b15801561086257600080fd5b505afa158015610876573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089a9190611243565b604051639350875560e01b81529091506001600160a01b037f00000000000000000000000050fe5165be08095a1f4cd96877cc54b3cc2ea08e16906393508755906108ef908b908b908b908b90600401611605565b600060405180830381600087803b15801561090957600080fd5b505af115801561091d573d6000803e3d6000fd5b5050505060007f00000000000000000000000069c53679ec1c06f3275b64c428e8cd069a2d39666001600160a01b031663b40494e56040518163ffffffff1660e01b815260040160206040518083038186803b15801561097c57600080fd5b505afa158015610990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b49190611243565b905060007f00000000000000000000000069c53679ec1c06f3275b64c428e8cd069a2d39666001600160a01b03166312e778b66040518163ffffffff1660e01b815260040160206040518083038186803b158015610a1157600080fd5b505afa158015610a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a499190611243565b6004549091508a037f000000000000000000000000000000000000000000000000000000000000018002610a808383878785610e62565b60048b90556001861115610aa95760008b81526005602090815260408083208a84529091528120555b5050505050610ad0565b600086815260056020908152604080832085845290915290208190555b505050505050565b610ae0610db6565b6001600160a01b0316610af1610623565b6001600160a01b031614610b175760405162461bcd60e51b815260040161033690611555565b6001600160a01b038216610b3d5760405162461bcd60e51b8152600401610336906113f4565b610b48600783610dba565b15610b655760405162461bcd60e51b8152600401610336906115b1565b610b70600783610f00565b507fb251eb052afc73ffd02ffe85ad79990a8b3fed60d76dbc2fa2fdd7123dffd91482604051610ba09190611321565b60405180910390a1610bb181610ded565b5050565b6000610bc16007610f15565b905090565b60606000610bd46007610f15565b90508067ffffffffffffffff81118015610bed57600080fd5b50604051908082528060200260200182016040528015610c17578160200160208202803683370190505b50915060005b81811015610c5c57610c30600782610f20565b838281518110610c3c57fe5b6001600160a01b0390921660209283029190910190910152600101610c1d565b505090565b7f00000000000000000000000050fe5165be08095a1f4cd96877cc54b3cc2ea08e81565b60035481565b7f00000000000000000000000069c53679ec1c06f3275b64c428e8cd069a2d396681565b7f00000000000000000000000000000000000000000000000000000000000000e181565b60045481565b610ce1610db6565b6001600160a01b0316610cf2610623565b6001600160a01b031614610d185760405162461bcd60e51b815260040161033690611555565b6001600160a01b038116610d3e5760405162461bcd60e51b81526004016103369061141d565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600560209081526000928352604080842090915290825290205481565b3390565b6000610dcf836001600160a01b038416610f2c565b90505b92915050565b6000610dcf836001600160a01b038416610f44565b60028190556040517ff18f88786aae85a652aadb99a82462616489a33370c9bcc7b245906812ef7cd190610e229083906113a9565b60405180910390a150565b60018190556040517ff835e8dcf6b25346fd90f601a094c8c85d19413e1a94da9936c01137cc4942b090610e229083906113a9565b831580610e6d575081155b15610e7757610ef9565b6000610e83868661100a565b90506000610e91858561100a565b9050600081831015610ea557828203610ea9565b8183035b9050610ec06001548361102890919063ffffffff16565b84610ecf836301e1338061103c565b81610ed657fe5b041115610ef55760405162461bcd60e51b81526004016103369061148d565b5050505b5050505050565b6000610dcf836001600160a01b038416611076565b6000610dd2826110c0565b6000610dcf83836110c4565b60009081526001919091016020526040902054151590565b600081815260018301602052604081205480156110005783546000198083019190810190600090879083908110610f7757fe5b9060005260206000200154905080876000018481548110610f9457fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080610fc457fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610dd2565b6000915050610dd2565b6000610dcf8261102285670de0b6b3a764000061103c565b90611109565b6000610dcf670de0b6b3a764000061102285855b60008261104b57506000610dd2565b8282028284828161105857fe5b0414610dcf5760405162461bcd60e51b815260040161033690611514565b60006110828383610f2c565b6110b857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610dd2565b506000610dd2565b5490565b815460009082106110e75760405162461bcd60e51b8152600401610336906113b2565b8260000182815481106110f657fe5b9060005260206000200154905092915050565b600080821161112a5760405162461bcd60e51b8152600401610336906114b7565b81838161113357fe5b049392505050565b80356001600160a01b0381168114610dd257600080fd5b60008083601f840112611163578182fd5b50813567ffffffffffffffff81111561117a578182fd5b60208301915083602060808302850101111561119557600080fd5b9250929050565b6000602082840312156111ad578081fd5b610dcf838361113b565b600080604083850312156111c9578081fd5b6111d3848461113b565b946020939093013593505050565b6000806000604084860312156111f5578081fd5b833567ffffffffffffffff81111561120b578182fd5b61121786828701611152565b909790965060209590950135949350505050565b60006020828403121561123c578081fd5b5035919050565b600060208284031215611254578081fd5b5051919050565b60008060008060608587031215611270578081fd5b84359350602085013567ffffffffffffffff81111561128d578182fd5b61129987828801611152565b9598909750949560400135949350505050565b600080604083850312156112be578182fd5b50508035926020909101359150565b60008284526020808501945082825b85811015611316578135875282820135838801526040808301359088015260608083013590880152608096870196909101906001016112dc565b509495945050505050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b818110156113765783516001600160a01b031683529284019291840191600101611351565b50909695505050505050565b6000606082526113966060830186886112cd565b6020830194909452506040015292915050565b90815260200190565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252600f908201526e496e76616c6964206164647265737360881b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526010908201526f105b1c9958591e481c995c1bdc9d195960821b604082015260600190565b60208082526010908201526f416e6e75616c206d61782064656c746160801b604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b6020808252600c908201526b2737ba10309036b2b6b132b960a11b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600d908201526c092dcecc2d8d2c840cae0dec6d609b1b604082015260600190565b60208082526010908201526f20b63932b0b23c90309036b2b6b132b960811b604082015260600190565b60208082526010908201526f13595b58995c881b9bdd08199bdd5b9960821b604082015260600190565b60008582526060602083015261161f6060830185876112cd565b905082604083015295945050505050565b92835260208301919091526001600160a01b031660408201526060019056fea2646970667358221220216c6bc760f91f507ebd9ab2df843ba314d3e81e9023e7eda2450d056127c09864736f6c634300060c0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000050fe5165be08095a1f4cd96877cc54b3cc2ea08e00000000000000000000000000000000000000000000000000000000000000e10000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000005fc630570000000000000000000000000000000000000000000000000429d069189e0000

-----Decoded View---------------
Arg [0] : strategy_ (address): 0x50fe5165BE08095a1f4cd96877Cc54B3cC2EA08E
Arg [1] : reportableEpochInterval_ (uint256): 225
Arg [2] : secondsPerEpoch_ (uint256): 384
Arg [3] : genesisTime_ (uint256): 1606824023
Arg [4] : annualMaxChange_ (uint256): 300000000000000000

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 00000000000000000000000050fe5165be08095a1f4cd96877cc54b3cc2ea08e
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000e1
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000180
Arg [3] : 000000000000000000000000000000000000000000000000000000005fc63057
Arg [4] : 0000000000000000000000000000000000000000000000000429d069189e0000


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
Loading...
Loading
[ 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.