HYPE Price: $22.30 (+0.72%)
 

Overview

HYPE Balance

HyperEVM LogoHyperEVM LogoHyperEVM Logo0 HYPE

HYPE Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PythOracle

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 200 runs

Other Settings:
cancun EvmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {DecimalsLib} from "../../libraries/DecimalsLib.sol";
import {IPyth} from "../../interfaces/IPyth.sol";
import {IPriceFeed} from "../../interfaces/IPriceFeed.sol";

contract PythOracle is IPriceFeed, Ownable {
    using DecimalsLib for uint256;

    IPyth public immutable PYTH;
    bytes32 public immutable PYTH_ID;

    uint256 pythHeartBeat = 1 hours;

    constructor(address _pythAddress, bytes32 _pythId) Ownable(msg.sender) {
        PYTH = IPyth(_pythAddress);
        PYTH_ID = _pythId;
    }

    function setPythHeartBeat(uint256 _newPythHeartBeat) external onlyOwner {
        pythHeartBeat = _newPythHeartBeat;
    }

    function fetchPrice() external view returns (uint256) {
        IPyth.Price memory token0Feed = PYTH.getPriceNoOlderThan(PYTH_ID, pythHeartBeat);

        return uint256(uint64(token0Feed.price)).to18Decimals(uint8(uint32(-token0Feed.expo)));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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 Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 4 of 6 : IPriceFeed.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

interface IPriceFeed {
    function fetchPrice() external view returns (uint256);
}

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

interface IPyth {
    struct Price {
        // Price
        int64 price;
        // Confidence interval around the price
        uint64 conf;
        // Price exponent
        int32 expo;
        // Unix timestamp describing when the price was published
        uint256 publishTime;
    }

    struct PriceFeed {
        // The price ID.
        bytes32 id;
        // Latest available price
        Price price;
        // Latest available exponentially-weighted moving average price
        Price emaPrice;
    }

    function getPrice(bytes32 id) external view returns (Price memory);
    function getPriceNoOlderThan(bytes32 id, uint256 timeFrame) external view returns (Price memory);
    function getPriceUnsafe(bytes32 id) external view returns (Price memory);
    function getUpdateFee(bytes[] calldata id) external view returns (uint256[] calldata);
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

library DecimalsLib {
    function to18Decimals(uint256 _amount, uint8 _from) internal pure returns (uint256) {
        return toDecimals(_amount, _from, 18);
    }

    function toDecimals(uint256 _amount, uint8 _from, uint8 _to) internal pure returns (uint256) {
        if (_from == _to) {
            return _amount;
        } else if (_from < _to) {
            uint256 factor = 10 ** (_to - _from);
            return _amount * factor;
        } else {
            uint256 factor = 10 ** (_from - _to);
            return _amount / factor;
        }
    }
}

Settings
{
  "evmVersion": "cancun",
  "libraries": {},
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "remappings": [
    "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
    "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
    "solady/=node_modules/solady/src/",
    "forge-std/=node_modules/forge-std/src/"
  ],
  "viaIR": true
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_pythAddress","type":"address"},{"internalType":"bytes32","name":"_pythId","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"PYTH","outputs":[{"internalType":"contract IPyth","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PYTH_ID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fetchPrice","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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPythHeartBeat","type":"uint256"}],"name":"setPythHeartBeat","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c0346100ef57601f6105ad38819003918201601f19168301916001600160401b038311848410176100f35780849260409485528339810103126100ef5780516001600160a01b03811691908290036100ef576020015133156100dc575f8054336001600160a01b0319821681178355604051949290916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3610e1060015560805260a0526104a5908161010882396080518181816101aa0152610263015260a0518181816101f001526102320152f35b631e4fbdf760e01b5f525f60045260245ffd5b5f80fd5b634e487b7160e01b5f52604160045260245ffdfe6080806040526004361015610012575f80fd5b5f3560e01c9081630fdb11cf14610213575080631330e162146101d957806367e406d514610195578063715018a61461013e5780638666519d1461011d5780638da5cb5b146100f65763f2fde38b14610069575f80fd5b346100f25760203660031901126100f2576004356001600160a01b038116908190036100f2576100976103b6565b80156100df575f80546001600160a01b03198116831782556001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3005b631e4fbdf760e01b5f525f60045260245ffd5b5f80fd5b346100f2575f3660031901126100f2575f546040516001600160a01b039091168152602090f35b346100f25760203660031901126100f2576101366103b6565b600435600155005b346100f2575f3660031901126100f2576101566103b6565b5f80546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346100f2575f3660031901126100f2576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346100f2575f3660031901126100f25760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b346100f2575f3660031901126100f25760015463052571af60e51b82527f0000000000000000000000000000000000000000000000000000000000000000600483015260248201526080816044817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156103ab575f916102ea575b50604067ffffffffffffffff82511691015160030b637fffffff1981146102d65760209160ff6102ce925f031690610401565b604051908152f35b634e487b7160e01b5f52601160045260245ffd5b905060803d6080116103a4575b601f8101601f1916820167ffffffffffffffff811183821017610390576080918391604052810103126100f257604051906080820182811067ffffffffffffffff8211176103905760405280518060070b81036100f2578252602081015167ffffffffffffffff811681036100f25760208301526040810151908160030b82036100f2576060916040840152015160608201528161029b565b634e487b7160e01b5f52604160045260245ffd5b503d6102f7565b6040513d5f823e3d90fd5b5f546001600160a01b031633036103c957565b63118cdaa760e01b5f523360045260245ffd5b9060ff8091169116039060ff82116102d657565b60ff16604d81116102d657600a0a90565b9060ff81166012810361041357505090565b601211156104425761042961042e9160126103dc565b6103f0565b908181029181830414901517156102d65790565b6104296012610450926103dc565b90811561045b570490565b634e487b7160e01b5f52601260045260245ffdfea2646970667358221220b6005c93018e4a6511b98185bba3b6fcad75ab0f0b355e0dbfc7b9782bdcef8564736f6c634300081c0033000000000000000000000000e9d69cdd6fe41e7b621b4a688c5d1a68cb5c8adc4279e31cc369bbcc2faf022b382b080e32a8e689ff20fbc530d2a603eb6cd98b

Deployed Bytecode

0x6080806040526004361015610012575f80fd5b5f3560e01c9081630fdb11cf14610213575080631330e162146101d957806367e406d514610195578063715018a61461013e5780638666519d1461011d5780638da5cb5b146100f65763f2fde38b14610069575f80fd5b346100f25760203660031901126100f2576004356001600160a01b038116908190036100f2576100976103b6565b80156100df575f80546001600160a01b03198116831782556001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3005b631e4fbdf760e01b5f525f60045260245ffd5b5f80fd5b346100f2575f3660031901126100f2575f546040516001600160a01b039091168152602090f35b346100f25760203660031901126100f2576101366103b6565b600435600155005b346100f2575f3660031901126100f2576101566103b6565b5f80546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346100f2575f3660031901126100f2576040517f000000000000000000000000e9d69cdd6fe41e7b621b4a688c5d1a68cb5c8adc6001600160a01b03168152602090f35b346100f2575f3660031901126100f25760206040517f4279e31cc369bbcc2faf022b382b080e32a8e689ff20fbc530d2a603eb6cd98b8152f35b346100f2575f3660031901126100f25760015463052571af60e51b82527f4279e31cc369bbcc2faf022b382b080e32a8e689ff20fbc530d2a603eb6cd98b600483015260248201526080816044817f000000000000000000000000e9d69cdd6fe41e7b621b4a688c5d1a68cb5c8adc6001600160a01b03165afa9081156103ab575f916102ea575b50604067ffffffffffffffff82511691015160030b637fffffff1981146102d65760209160ff6102ce925f031690610401565b604051908152f35b634e487b7160e01b5f52601160045260245ffd5b905060803d6080116103a4575b601f8101601f1916820167ffffffffffffffff811183821017610390576080918391604052810103126100f257604051906080820182811067ffffffffffffffff8211176103905760405280518060070b81036100f2578252602081015167ffffffffffffffff811681036100f25760208301526040810151908160030b82036100f2576060916040840152015160608201528161029b565b634e487b7160e01b5f52604160045260245ffd5b503d6102f7565b6040513d5f823e3d90fd5b5f546001600160a01b031633036103c957565b63118cdaa760e01b5f523360045260245ffd5b9060ff8091169116039060ff82116102d657565b60ff16604d81116102d657600a0a90565b9060ff81166012810361041357505090565b601211156104425761042961042e9160126103dc565b6103f0565b908181029181830414901517156102d65790565b6104296012610450926103dc565b90811561045b570490565b634e487b7160e01b5f52601260045260245ffdfea2646970667358221220b6005c93018e4a6511b98185bba3b6fcad75ab0f0b355e0dbfc7b9782bdcef8564736f6c634300081c0033

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

000000000000000000000000e9d69cdd6fe41e7b621b4a688c5d1a68cb5c8adc4279e31cc369bbcc2faf022b382b080e32a8e689ff20fbc530d2a603eb6cd98b

-----Decoded View---------------
Arg [0] : _pythAddress (address): 0xe9d69CdD6Fe41e7B621B4A688C5D1a68cB5c8ADc
Arg [1] : _pythId (bytes32): 0x4279e31cc369bbcc2faf022b382b080e32a8e689ff20fbc530d2a603eb6cd98b

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000e9d69cdd6fe41e7b621b4a688c5d1a68cb5c8adc
Arg [1] : 4279e31cc369bbcc2faf022b382b080e32a8e689ff20fbc530d2a603eb6cd98b


Block Transaction Gas Used Reward
view all blocks ##produced##

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

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.