ETH Price: $1,883.86 (-6.06%)

Contract

0xC51C787b68bFA569AC237B6bfdeBaB2C1E048E21

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

> 10 Internal Transactions found.

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
1074774632023-07-28 14:15:03609 days ago1690553703
0xC51C787b...C1E048E21
0 ETH
1074386712023-07-27 16:41:59609 days ago1690476119
0xC51C787b...C1E048E21
0 ETH
1074342622023-07-27 14:15:01610 days ago1690467301
0xC51C787b...C1E048E21
0 ETH
1073910642023-07-26 14:15:05611 days ago1690380905
0xC51C787b...C1E048E21
0 ETH
1073509642023-07-25 15:58:25611 days ago1690300705
0xC51C787b...C1E048E21
0 ETH
1073478632023-07-25 14:15:03612 days ago1690294503
0xC51C787b...C1E048E21
0 ETH
1073046652023-07-24 14:15:07613 days ago1690208107
0xC51C787b...C1E048E21
0 ETH
1072614642023-07-23 14:15:05614 days ago1690121705
0xC51C787b...C1E048E21
0 ETH
1072182652023-07-22 14:15:07615 days ago1690035307
0xC51C787b...C1E048E21
0 ETH
1071750622023-07-21 14:15:01616 days ago1689948901
0xC51C787b...C1E048E21
0 ETH
1070886682023-07-19 14:15:13618 days ago1689776113
0xC51C787b...C1E048E21
0 ETH
1070454662023-07-18 14:15:09619 days ago1689689709
0xC51C787b...C1E048E21
0 ETH
1070022632023-07-17 14:15:03620 days ago1689603303
0xC51C787b...C1E048E21
0 ETH
1069590632023-07-16 14:15:03621 days ago1689516903
0xC51C787b...C1E048E21
0 ETH
1069158652023-07-15 14:15:07622 days ago1689430507
0xC51C787b...C1E048E21
0 ETH
1068726632023-07-14 14:15:03623 days ago1689344103
0xC51C787b...C1E048E21
0 ETH
1068294822023-07-13 14:15:41624 days ago1689257741
0xC51C787b...C1E048E21
0 ETH
1067862652023-07-12 14:15:07625 days ago1689171307
0xC51C787b...C1E048E21
0 ETH
1066998662023-07-10 14:15:09627 days ago1688998509
0xC51C787b...C1E048E21
0 ETH
1066566662023-07-09 14:15:09628 days ago1688912109
0xC51C787b...C1E048E21
0 ETH
1066134642023-07-08 14:15:05629 days ago1688825705
0xC51C787b...C1E048E21
0 ETH
1065702652023-07-07 14:15:07630 days ago1688739307
0xC51C787b...C1E048E21
0 ETH
1065270672023-07-06 14:15:11631 days ago1688652911
0xC51C787b...C1E048E21
0 ETH
1064838652023-07-05 14:15:07632 days ago1688566507
0xC51C787b...C1E048E21
0 ETH
1064406642023-07-04 14:15:05633 days ago1688480105
0xC51C787b...C1E048E21
0 ETH
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
InternetBondRatioFeed_R2

Compiler Version
v0.8.6+commit.11564f7e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 6 : InternetBondRatioFeed_R2.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.6;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "../interfaces/IInternetBondRatioFeed.sol";

contract InternetBondRatioFeed_R2 is
    OwnableUpgradeable,
    IInternetBondRatioFeed
{
    event OperatorAdded(address operator);
    event OperatorRemoved(address operator);

    struct HistoricalRatios {
        uint64[9] historicalRatios;
        uint40 lastUpdate;
    }

    mapping(address => bool) _isOperator;
    mapping(address => uint256) private _ratios;

    mapping(address => HistoricalRatios) public historicalRatios;

    uint32 public constant MAX_THRESHOLD = uint32(1e8); // 100000000

    /// @dev diff between the current ratio and a new one in %(0.000001 ... 100%)
    uint256 private _ratioThreshold;

    function initialize(address operator) public initializer {
        __Ownable_init();
        _isOperator[operator] = true;
    }

    function updateRatioBatch(
        address[] calldata addresses,
        uint256[] calldata ratios
    ) public override onlyOperator {
        require(addresses.length == ratios.length, "corrupted ratio data");
        for (uint256 i = 0; i < addresses.length; i++) {
            HistoricalRatios storage hisRatio = historicalRatios[addresses[i]];

            require(
                _ratioRules(
                    hisRatio.lastUpdate,
                    ratios[i],
                    _ratios[addresses[i]]
                ),
                "new ratio is impossible"
            );

            // let's compare with a new ratio
            _ratios[addresses[i]] = ratios[i];

            if (block.timestamp - hisRatio.lastUpdate > 1 days - 1 minutes) {
                uint64 latestOffset = hisRatio.historicalRatios[0];
                hisRatio.historicalRatios[
                    ((latestOffset + 1) % 8) + 1
                ] = uint64(ratios[i]);
                hisRatio.historicalRatios[0] = latestOffset + 1;
                hisRatio.lastUpdate = uint40(block.timestamp);
            }
        }
    }

    function _ratioRules(
        uint40 lastUpdated,
        uint256 newRatio,
        uint256 oldRatio
    ) internal view returns (bool) {
        require(_ratioThreshold > 0, "ratio threshold is not set");
        require(
            block.timestamp - lastUpdated >= 12 hours,
            "ratio was updated less than 12 hours ago"
        );
        // initialization of the first ratio -> skip checkings
        if (oldRatio == 0) {
            return true;
        }
        // new ratio should be not greater than a previous one
        if (newRatio > oldRatio) {
            return false;
        }
        // new ratio should be in the range (oldRatio - threshold , oldRatio]
        uint256 threshold = (oldRatio * _ratioThreshold) / MAX_THRESHOLD;
        if (newRatio > oldRatio - threshold) {
            return true;
        }

        return false;
    }

    function averagePercentageRate(
        address addr,
        uint256 day
    ) external view returns (uint256) {
        require(day > 0 && day < 8, "day should be from 1 to 7");

        HistoricalRatios storage hisRatio = historicalRatios[addr];
        uint64 latestOffset = hisRatio.historicalRatios[0];

        uint256 oldestRatio = hisRatio.historicalRatios[
            ((latestOffset - day) % 8) + 1
        ];
        uint256 newestRatio = hisRatio.historicalRatios[
            ((latestOffset) % 8) + 1
        ];

        if (oldestRatio < newestRatio) {
            return 0;
        }

        return
            ((oldestRatio - newestRatio) * 10 ** 20 * 365) /
            (oldestRatio * (day));
    }

    function repairRatioFor(address token, uint256 ratio) public onlyOwner {
        require(ratio != 0, "ratio is zero");
        _ratios[token] = ratio;
    }

    function getRatioFor(address token) public view override returns (uint256) {
        return _ratios[token];
    }

    function addOperator(address operator) public onlyOwner {
        require(operator != address(0x0), "operator must be non-zero");
        require(!_isOperator[operator], "already operator");
        _isOperator[operator] = true;
        emit OperatorAdded(operator);
    }

    function removeOperator(address operator) public onlyOwner {
        require(_isOperator[operator], "not an operator");
        delete _isOperator[operator];
        emit OperatorRemoved(operator);
    }

    function setRatioThreshold(uint256 newValue) public onlyOwner {
        require(
            newValue < MAX_THRESHOLD && newValue > 0,
            "wrong value for ratio threshold"
        );
        uint256 oldValue = _ratioThreshold;
        _ratioThreshold = newValue;
        emit RatioThresholdChanged(oldValue, newValue);
    }

    modifier onlyOperator() {
        require(
            msg.sender == owner() || _isOperator[msg.sender],
            "Operator: not allowed"
        );
        _;
    }
}

File 2 of 6 : IInternetBondRatioFeed.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.6;

interface IInternetBondRatioFeed {
    event RatioThresholdChanged(uint256 oldValue, uint256 newValue);

    function updateRatioBatch(
        address[] calldata addresses,
        uint256[] calldata ratios
    ) external;

    function getRatioFor(address) external view returns (uint256);
}

File 3 of 6 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 4 of 6 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 5 of 6 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 6 of 6 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        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 {
        _transferOwnership(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");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

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

Contract Security Audit

Contract ABI

API
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"}],"name":"OperatorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"}],"name":"OperatorRemoved","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":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"RatioThresholdChanged","type":"event"},{"inputs":[],"name":"MAX_THRESHOLD","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"addOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"day","type":"uint256"}],"name":"averagePercentageRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getRatioFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"historicalRatios","outputs":[{"internalType":"uint40","name":"lastUpdate","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"removeOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"ratio","type":"uint256"}],"name":"repairRatioFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"setRatioThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"ratios","type":"uint256[]"}],"name":"updateRatioBatch","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5061109f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c80639870d7fe1161008c578063b037d56a11610066578063b037d56a146101b4578063c4d66de8146101c7578063ec653c4b146101da578063f2fde38b1461021a57600080fd5b80639870d7fe14610165578063a1f1d48d14610178578063ac8a584a146101a157600080fd5b806308af5431146100d45780632364753a146100f95780632acaaff41461010e5780632ef86a1f1461012f578063715018a6146101425780638da5cb5b1461014a575b600080fd5b6100df6305f5e10081565b60405163ffffffff90911681526020015b60405180910390f35b61010c610107366004610ee1565b61022d565b005b61012161011c366004610e4c565b6102df565b6040519081526020016100f0565b61010c61013d366004610e4c565b610475565b61010c6104d6565b6033546040516001600160a01b0390911681526020016100f0565b61010c610173366004610e31565b6104ea565b610121610186366004610e31565b6001600160a01b031660009081526066602052604090205490565b61010c6101af366004610e31565b6105ff565b61010c6101c2366004610e76565b6106b2565b61010c6101d5366004610e31565b6109ed565b6102046101e8366004610e31565b60676020526000908152604090206003015464ffffffffff1681565b60405164ffffffffff90911681526020016100f0565b61010c610228366004610e31565b610b1e565b610235610b97565b6305f5e100811080156102485750600081115b6102995760405162461bcd60e51b815260206004820152601f60248201527f77726f6e672076616c756520666f7220726174696f207468726573686f6c640060448201526064015b60405180910390fd5b606880549082905560408051828152602081018490527f661e4cadf2d36ec16a59d60dcfeebe23f9be2aec99852725798a4be99790840e91015b60405180910390a15050565b600080821180156102f05750600882105b61033c5760405162461bcd60e51b815260206004820152601960248201527f6461792073686f756c642062652066726f6d203120746f2037000000000000006044820152606401610290565b6001600160a01b0383166000908152606760205260408120805490916001600160401b03909116908260086103718785610fbb565b61037b9190610fed565b610386906001610f45565b6009811061039657610396611053565b60048104909101546001600160401b036008600390931683026101000a90910416915060009084906103c89085611001565b6103d3906001610f5d565b6001600160401b0316600981106103ec576103ec611053565b600491828204019190066008029054906101000a90046001600160401b03166001600160401b031690508082101561042b57600094505050505061046f565b6104358683610f9c565b61043f8284610fbb565b6104529068056bc75e2d63100000610f9c565b61045e9061016d610f9c565b6104689190610f88565b9450505050505b92915050565b61047d610b97565b806104ba5760405162461bcd60e51b815260206004820152600d60248201526c726174696f206973207a65726f60981b6044820152606401610290565b6001600160a01b03909116600090815260666020526040902055565b6104de610b97565b6104e86000610bf1565b565b6104f2610b97565b6001600160a01b0381166105485760405162461bcd60e51b815260206004820152601960248201527f6f70657261746f72206d757374206265206e6f6e2d7a65726f000000000000006044820152606401610290565b6001600160a01b03811660009081526065602052604090205460ff16156105a45760405162461bcd60e51b815260206004820152601060248201526f30b63932b0b23c9037b832b930ba37b960811b6044820152606401610290565b6001600160a01b038116600081815260656020908152604091829020805460ff1916600117905590519182527fac6fa858e9350a46cec16539926e0fde25b7629f84b5a72bffaae4df888ae86d91015b60405180910390a150565b610607610b97565b6001600160a01b03811660009081526065602052604090205460ff166106615760405162461bcd60e51b815260206004820152600f60248201526e3737ba1030b71037b832b930ba37b960891b6044820152606401610290565b6001600160a01b038116600081815260656020908152604091829020805460ff1916905590519182527f80c0b871b97b595b16a7741c1b06fed0c6f6f558639f18ccbce50724325dc40d91016105f4565b6033546001600160a01b03163314806106da57503360009081526065602052604090205460ff165b61071e5760405162461bcd60e51b815260206004820152601560248201527413dc195c985d1bdc8e881b9bdd08185b1b1bddd959605a1b6044820152606401610290565b8281146107645760405162461bcd60e51b8152602060048201526014602482015273636f7272757074656420726174696f206461746160601b6044820152606401610290565b60005b838110156109e65760006067600087878581811061078757610787611053565b905060200201602081019061079c9190610e31565b6001600160a01b03168152602081019190915260400160002060038101549091506108329064ffffffffff168585858181106107da576107da611053565b90506020020135606660008a8a888181106107f7576107f7611053565b905060200201602081019061080c9190610e31565b6001600160a01b03166001600160a01b0316815260200190815260200160002054610c43565b61087e5760405162461bcd60e51b815260206004820152601760248201527f6e657720726174696f20697320696d706f737369626c650000000000000000006044820152606401610290565b83838381811061089057610890611053565b90506020020135606660008888868181106108ad576108ad611053565b90506020020160208101906108c29190610e31565b6001600160a01b03168152602081019190915260400160002055600381015462015144906108f79064ffffffffff1642610fbb565b11156109d35780546001600160401b031684848481811061091a5761091a611053565b60200291909101359050826008610932846001610f5d565b61093c9190611001565b610947906001610f5d565b6001600160401b03166009811061096057610960611053565b600491828204019190066008026101000a8154816001600160401b0302191690836001600160401b0316021790555080600161099c9190610f5d565b825467ffffffffffffffff19166001600160401b03919091161782555060038101805464ffffffffff19164264ffffffffff161790555b50806109de81610fd2565b915050610767565b5050505050565b600054610100900460ff1615808015610a0d5750600054600160ff909116105b80610a275750303b158015610a27575060005460ff166001145b610a8a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610290565b6000805460ff191660011790558015610aad576000805461ff0019166101001790555b610ab5610d70565b6001600160a01b0382166000908152606560205260409020805460ff191660011790558015610b1a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020016102d3565b5050565b610b26610b97565b6001600160a01b038116610b8b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610290565b610b9481610bf1565b50565b6033546001600160a01b031633146104e85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610290565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008060685411610c965760405162461bcd60e51b815260206004820152601a60248201527f726174696f207468726573686f6c64206973206e6f74207365740000000000006044820152606401610290565b61a8c0610caa64ffffffffff861642610fbb565b1015610d095760405162461bcd60e51b815260206004820152602860248201527f726174696f207761732075706461746564206c657373207468616e20313220686044820152676f7572732061676f60c01b6064820152608401610290565b81610d1657506001610d69565b81831115610d2657506000610d69565b6068546000906305f5e10090610d3c9085610f9c565b610d469190610f88565b9050610d528184610fbb565b841115610d63576001915050610d69565b60009150505b9392505050565b600054610100900460ff16610d975760405162461bcd60e51b815260040161029090610efa565b6104e8600054610100900460ff16610dc15760405162461bcd60e51b815260040161029090610efa565b6104e833610bf1565b80356001600160a01b0381168114610de157600080fd5b919050565b60008083601f840112610df857600080fd5b5081356001600160401b03811115610e0f57600080fd5b6020830191508360208260051b8501011115610e2a57600080fd5b9250929050565b600060208284031215610e4357600080fd5b610d6982610dca565b60008060408385031215610e5f57600080fd5b610e6883610dca565b946020939093013593505050565b60008060008060408587031215610e8c57600080fd5b84356001600160401b0380821115610ea357600080fd5b610eaf88838901610de6565b90965094506020870135915080821115610ec857600080fd5b50610ed587828801610de6565b95989497509550505050565b600060208284031215610ef357600080fd5b5035919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008219821115610f5857610f58611027565b500190565b60006001600160401b03808316818516808303821115610f7f57610f7f611027565b01949350505050565b600082610f9757610f9761103d565b500490565b6000816000190483118215151615610fb657610fb6611027565b500290565b600082821015610fcd57610fcd611027565b500390565b6000600019821415610fe657610fe6611027565b5060010190565b600082610ffc57610ffc61103d565b500690565b60006001600160401b038084168061101b5761101b61103d565b92169190910692915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fdfea2646970667358221220c1d1afe3b2a23935193396451893c382c6a4d293999058752267e34b4a6595a164736f6c63430008060033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80639870d7fe1161008c578063b037d56a11610066578063b037d56a146101b4578063c4d66de8146101c7578063ec653c4b146101da578063f2fde38b1461021a57600080fd5b80639870d7fe14610165578063a1f1d48d14610178578063ac8a584a146101a157600080fd5b806308af5431146100d45780632364753a146100f95780632acaaff41461010e5780632ef86a1f1461012f578063715018a6146101425780638da5cb5b1461014a575b600080fd5b6100df6305f5e10081565b60405163ffffffff90911681526020015b60405180910390f35b61010c610107366004610ee1565b61022d565b005b61012161011c366004610e4c565b6102df565b6040519081526020016100f0565b61010c61013d366004610e4c565b610475565b61010c6104d6565b6033546040516001600160a01b0390911681526020016100f0565b61010c610173366004610e31565b6104ea565b610121610186366004610e31565b6001600160a01b031660009081526066602052604090205490565b61010c6101af366004610e31565b6105ff565b61010c6101c2366004610e76565b6106b2565b61010c6101d5366004610e31565b6109ed565b6102046101e8366004610e31565b60676020526000908152604090206003015464ffffffffff1681565b60405164ffffffffff90911681526020016100f0565b61010c610228366004610e31565b610b1e565b610235610b97565b6305f5e100811080156102485750600081115b6102995760405162461bcd60e51b815260206004820152601f60248201527f77726f6e672076616c756520666f7220726174696f207468726573686f6c640060448201526064015b60405180910390fd5b606880549082905560408051828152602081018490527f661e4cadf2d36ec16a59d60dcfeebe23f9be2aec99852725798a4be99790840e91015b60405180910390a15050565b600080821180156102f05750600882105b61033c5760405162461bcd60e51b815260206004820152601960248201527f6461792073686f756c642062652066726f6d203120746f2037000000000000006044820152606401610290565b6001600160a01b0383166000908152606760205260408120805490916001600160401b03909116908260086103718785610fbb565b61037b9190610fed565b610386906001610f45565b6009811061039657610396611053565b60048104909101546001600160401b036008600390931683026101000a90910416915060009084906103c89085611001565b6103d3906001610f5d565b6001600160401b0316600981106103ec576103ec611053565b600491828204019190066008029054906101000a90046001600160401b03166001600160401b031690508082101561042b57600094505050505061046f565b6104358683610f9c565b61043f8284610fbb565b6104529068056bc75e2d63100000610f9c565b61045e9061016d610f9c565b6104689190610f88565b9450505050505b92915050565b61047d610b97565b806104ba5760405162461bcd60e51b815260206004820152600d60248201526c726174696f206973207a65726f60981b6044820152606401610290565b6001600160a01b03909116600090815260666020526040902055565b6104de610b97565b6104e86000610bf1565b565b6104f2610b97565b6001600160a01b0381166105485760405162461bcd60e51b815260206004820152601960248201527f6f70657261746f72206d757374206265206e6f6e2d7a65726f000000000000006044820152606401610290565b6001600160a01b03811660009081526065602052604090205460ff16156105a45760405162461bcd60e51b815260206004820152601060248201526f30b63932b0b23c9037b832b930ba37b960811b6044820152606401610290565b6001600160a01b038116600081815260656020908152604091829020805460ff1916600117905590519182527fac6fa858e9350a46cec16539926e0fde25b7629f84b5a72bffaae4df888ae86d91015b60405180910390a150565b610607610b97565b6001600160a01b03811660009081526065602052604090205460ff166106615760405162461bcd60e51b815260206004820152600f60248201526e3737ba1030b71037b832b930ba37b960891b6044820152606401610290565b6001600160a01b038116600081815260656020908152604091829020805460ff1916905590519182527f80c0b871b97b595b16a7741c1b06fed0c6f6f558639f18ccbce50724325dc40d91016105f4565b6033546001600160a01b03163314806106da57503360009081526065602052604090205460ff165b61071e5760405162461bcd60e51b815260206004820152601560248201527413dc195c985d1bdc8e881b9bdd08185b1b1bddd959605a1b6044820152606401610290565b8281146107645760405162461bcd60e51b8152602060048201526014602482015273636f7272757074656420726174696f206461746160601b6044820152606401610290565b60005b838110156109e65760006067600087878581811061078757610787611053565b905060200201602081019061079c9190610e31565b6001600160a01b03168152602081019190915260400160002060038101549091506108329064ffffffffff168585858181106107da576107da611053565b90506020020135606660008a8a888181106107f7576107f7611053565b905060200201602081019061080c9190610e31565b6001600160a01b03166001600160a01b0316815260200190815260200160002054610c43565b61087e5760405162461bcd60e51b815260206004820152601760248201527f6e657720726174696f20697320696d706f737369626c650000000000000000006044820152606401610290565b83838381811061089057610890611053565b90506020020135606660008888868181106108ad576108ad611053565b90506020020160208101906108c29190610e31565b6001600160a01b03168152602081019190915260400160002055600381015462015144906108f79064ffffffffff1642610fbb565b11156109d35780546001600160401b031684848481811061091a5761091a611053565b60200291909101359050826008610932846001610f5d565b61093c9190611001565b610947906001610f5d565b6001600160401b03166009811061096057610960611053565b600491828204019190066008026101000a8154816001600160401b0302191690836001600160401b0316021790555080600161099c9190610f5d565b825467ffffffffffffffff19166001600160401b03919091161782555060038101805464ffffffffff19164264ffffffffff161790555b50806109de81610fd2565b915050610767565b5050505050565b600054610100900460ff1615808015610a0d5750600054600160ff909116105b80610a275750303b158015610a27575060005460ff166001145b610a8a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610290565b6000805460ff191660011790558015610aad576000805461ff0019166101001790555b610ab5610d70565b6001600160a01b0382166000908152606560205260409020805460ff191660011790558015610b1a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020016102d3565b5050565b610b26610b97565b6001600160a01b038116610b8b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610290565b610b9481610bf1565b50565b6033546001600160a01b031633146104e85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610290565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008060685411610c965760405162461bcd60e51b815260206004820152601a60248201527f726174696f207468726573686f6c64206973206e6f74207365740000000000006044820152606401610290565b61a8c0610caa64ffffffffff861642610fbb565b1015610d095760405162461bcd60e51b815260206004820152602860248201527f726174696f207761732075706461746564206c657373207468616e20313220686044820152676f7572732061676f60c01b6064820152608401610290565b81610d1657506001610d69565b81831115610d2657506000610d69565b6068546000906305f5e10090610d3c9085610f9c565b610d469190610f88565b9050610d528184610fbb565b841115610d63576001915050610d69565b60009150505b9392505050565b600054610100900460ff16610d975760405162461bcd60e51b815260040161029090610efa565b6104e8600054610100900460ff16610dc15760405162461bcd60e51b815260040161029090610efa565b6104e833610bf1565b80356001600160a01b0381168114610de157600080fd5b919050565b60008083601f840112610df857600080fd5b5081356001600160401b03811115610e0f57600080fd5b6020830191508360208260051b8501011115610e2a57600080fd5b9250929050565b600060208284031215610e4357600080fd5b610d6982610dca565b60008060408385031215610e5f57600080fd5b610e6883610dca565b946020939093013593505050565b60008060008060408587031215610e8c57600080fd5b84356001600160401b0380821115610ea357600080fd5b610eaf88838901610de6565b90965094506020870135915080821115610ec857600080fd5b50610ed587828801610de6565b95989497509550505050565b600060208284031215610ef357600080fd5b5035919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008219821115610f5857610f58611027565b500190565b60006001600160401b03808316818516808303821115610f7f57610f7f611027565b01949350505050565b600082610f9757610f9761103d565b500490565b6000816000190483118215151615610fb657610fb6611027565b500290565b600082821015610fcd57610fcd611027565b500390565b6000600019821415610fe657610fe6611027565b5060010190565b600082610ffc57610ffc61103d565b500690565b60006001600160401b038084168061101b5761101b61103d565b92169190910692915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fdfea2646970667358221220c1d1afe3b2a23935193396451893c382c6a4d293999058752267e34b4a6595a164736f6c63430008060033

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  ]

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.