Address Contract Verified
Address
0xd04A2e318E4557bB81344eA485B63d0D55732A37
Balance
0 ETH
Nonce
1
Code Size
4746 bytes
Creator
0x0F6e98A7...289d at tx 0x60ddcad8...263c7b
Indexed Transactions
0
Contract Bytecode
4746 bytes
0x6080604052600436106100c25760003560e01c80638205bf6a1161007f578063b633620c11610059578063b633620c14610272578063bc36c0a9146102af578063f98d06f0146102cb578063feaf968c146102f6576100c2565b80638205bf6a146101c95780639a6fc8f5146101f4578063b5ab58dc14610235576100c2565b806331189334146100c7578063313ce567146100f257806350d25bcd1461011d57806354fd4d5014610148578063668a0f02146101735780637284e4161461019e575b600080fd5b3480156100d357600080fd5b506100dc610325565b6040516100e9919061094d565b60405180910390f35b3480156100fe57600080fd5b5061010761032b565b6040516101149190610984565b60405180910390f35b34801561012957600080fd5b50610132610404565b60405161013f91906109b8565b60405180910390f35b34801561015457600080fd5b5061015d6104ba565b60405161016a91906109ec565b60405180910390f35b34801561017f57600080fd5b506101886104c3565b60405161019591906109ec565b60405180910390f35b3480156101aa57600080fd5b506101b36104d2565b6040516101c09190610a97565b60405180910390f35b3480156101d557600080fd5b506101de6104f2565b6040516101eb91906109ec565b60405180910390f35b34801561020057600080fd5b5061021b60048036038101906102169190610b0f565b6105a5565b60405161022c959493929190610b4b565b60405180910390f35b34801561024157600080fd5b5061025c60048036038101906102579190610bca565b610676565b60405161026991906109b8565b60405180910390f35b34801561027e57600080fd5b5061029960048036038101906102949190610bca565b610687565b6040516102a691906109ec565b60405180910390f35b6102c960048036038101906102c49190610c5c565b610698565b005b3480156102d757600080fd5b506102e0610838565b6040516102ed9190610d28565b60405180910390f35b34801561030257600080fd5b5061030b61085e565b60405161031c959493929190610b4b565b60405180910390f35b60005481565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166396834ad36000546040518263ffffffff1660e01b815260040161038b919061094d565b608060405180830381865afa1580156103a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cc9190610f02565b905080604001517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6103fe9190610f6b565b91505090565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a4ae35e0600054620151806040518363ffffffff1660e01b8152600401610469929190610fe3565b608060405180830381865afa158015610486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104aa9190610f02565b9050806000015160070b91505090565b60006001905090565b60006104cd6104f2565b905090565b60606040518060600160405280603e8152602001611217603e9139905090565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a4ae35e0600054620151806040518363ffffffff1660e01b8152600401610557929190610fe3565b608060405180830381865afa158015610574573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105989190610f02565b9050806060015191505090565b600080600080600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166396834ad36000546040518263ffffffff1660e01b815260040161060b919061094d565b608060405180830381865afa158015610628573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064c9190610f02565b905086816000015160070b826060015183606001518a955095509550955095505091939590929450565b6000610680610404565b9050919050565b60006106916104f2565b9050919050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d47eed4584846040518363ffffffff1660e01b81526004016106f792919061117f565b602060405180830381865afa158015610714573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073891906111a3565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ef9e5e288285856040518463ffffffff1660e01b815260040161079892919061117f565b6000604051808303818588803b1580156107b157600080fd5b505af11580156107c5573d6000803e3d6000fd5b50505050503373ffffffffffffffffffffffffffffffffffffffff16476040516107ee90611201565b60006040518083038185875af1925050503d806000811461082b576040519150601f19603f3d011682016040523d82523d6000602084013e610830565b606091505b505050505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600080600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166396834ad36000546040518263ffffffff1660e01b81526004016108c4919061094d565b608060405180830381865afa1580156108e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109059190610f02565b90508060600151955085816000015160070b826060015183606001518995509550955095509550509091929394565b6000819050919050565b61094781610934565b82525050565b6000602082019050610962600083018461093e565b92915050565b600060ff82169050919050565b61097e81610968565b82525050565b60006020820190506109996000830184610975565b92915050565b6000819050919050565b6109b28161099f565b82525050565b60006020820190506109cd60008301846109a9565b92915050565b6000819050919050565b6109e6816109d3565b82525050565b6000602082019050610a0160008301846109dd565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610a41578082015181840152602081019050610a26565b60008484015250505050565b6000601f19601f8301169050919050565b6000610a6982610a07565b610a738185610a12565b9350610a83818560208601610a23565b610a8c81610a4d565b840191505092915050565b60006020820190508181036000830152610ab18184610a5e565b905092915050565b6000604051905090565b600080fd5b600080fd5b600069ffffffffffffffffffff82169050919050565b610aec81610acd565b8114610af757600080fd5b50565b600081359050610b0981610ae3565b92915050565b600060208284031215610b2557610b24610ac3565b5b6000610b3384828501610afa565b91505092915050565b610b4581610acd565b82525050565b600060a082019050610b606000830188610b3c565b610b6d60208301876109a9565b610b7a60408301866109dd565b610b8760608301856109dd565b610b946080830184610b3c565b9695505050505050565b610ba7816109d3565b8114610bb257600080fd5b50565b600081359050610bc481610b9e565b92915050565b600060208284031215610be057610bdf610ac3565b5b6000610bee84828501610bb5565b91505092915050565b600080fd5b600080fd5b600080fd5b60008083601f840112610c1c57610c1b610bf7565b5b8235905067ffffffffffffffff811115610c3957610c38610bfc565b5b602083019150836020820283011115610c5557610c54610c01565b5b9250929050565b60008060208385031215610c7357610c72610ac3565b5b600083013567ffffffffffffffff811115610c9157610c90610ac8565b5b610c9d85828601610c06565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610cee610ce9610ce484610ca9565b610cc9565b610ca9565b9050919050565b6000610d0082610cd3565b9050919050565b6000610d1282610cf5565b9050919050565b610d2281610d07565b82525050565b6000602082019050610d3d6000830184610d19565b92915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610d8082610a4d565b810181811067ffffffffffffffff82111715610d9f57610d9e610d48565b5b80604052505050565b6000610db2610ab9565b9050610dbe8282610d77565b919050565b60008160070b9050919050565b610dd981610dc3565b8114610de457600080fd5b50565b600081519050610df681610dd0565b92915050565b600067ffffffffffffffff82169050919050565b610e1981610dfc565b8114610e2457600080fd5b50565b600081519050610e3681610e10565b92915050565b60008160030b9050919050565b610e5281610e3c565b8114610e5d57600080fd5b50565b600081519050610e6f81610e49565b92915050565b600081519050610e8481610b9e565b92915050565b600060808284031215610ea057610e9f610d43565b5b610eaa6080610da8565b90506000610eba84828501610de7565b6000830152506020610ece84828501610e27565b6020830152506040610ee284828501610e60565b6040830152506060610ef684828501610e75565b60608301525092915050565b600060808284031215610f1857610f17610ac3565b5b6000610f2684828501610e8a565b91505092915050565b60008160000b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610f7682610f2f565b9150610f8183610f2f565b9250828202610f8f81610f2f565b9150808214610fa157610fa0610f3c565b5b5092915050565b6000819050919050565b6000610fcd610fc8610fc384610fa8565b610cc9565b6109d3565b9050919050565b610fdd81610fb2565b82525050565b6000604082019050610ff8600083018561093e565b6110056020830184610fd4565b9392505050565b600082825260208201905092915050565b6000819050919050565b600082825260208201905092915050565b82818337600083830152505050565b60006110538385611027565b9350611060838584611038565b61106983610a4d565b840190509392505050565b6000611081848484611047565b90509392505050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126110b6576110b5611094565b5b83810192508235915060208301925067ffffffffffffffff8211156110de576110dd61108a565b5b6001820236038313156110f4576110f361108f565b5b509250929050565b6000602082019050919050565b6000611115838561100c565b9350836020840285016111278461101d565b8060005b8781101561116d5784840389526111428284611099565b61114d868284611074565b9550611158846110fc565b935060208b019a50505060018101905061112b565b50829750879450505050509392505050565b6000602082019050818103600083015261119a818486611109565b90509392505050565b6000602082840312156111b9576111b8610ac3565b5b60006111c784828501610e75565b91505092915050565b600081905092915050565b50565b60006111eb6000836111d0565b91506111f6826111db565b600082019050919050565b600061120c826111de565b915081905091905056fe4120706f7274206f66206120636861696e6c696e6b2061676772656761746f7220706f77657265642062792070797468206e6574776f726b206665656473a2646970667358221220759d11a6f397a2c62d44eb299cfa05c27e6d056b13c128bac7bb8c431abdc30b64736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: paris
Optimization: No
IPyth.sol 160 lines
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import "./PythStructs.sol";
import "./IPythEvents.sol";
/// @title Consume prices from the Pyth Network (https://pyth.network/).
/// @dev Please refer to the guidance at https://docs.pyth.network/documentation/pythnet-price-feeds/best-practices for how to consume prices safely.
/// @author Pyth Data Association
interface IPyth is IPythEvents {
/// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time
function getValidTimePeriod() external view returns (uint validTimePeriod);
/// @notice Returns the price and confidence interval.
/// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds.
/// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getPrice(
bytes32 id
) external view returns (PythStructs.Price memory price);
/// @notice Returns the exponentially-weighted moving average price and confidence interval.
/// @dev Reverts if the EMA price is not available.
/// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getEmaPrice(
bytes32 id
) external view returns (PythStructs.Price memory price);
/// @notice Returns the price of a price feed without any sanity checks.
/// @dev This function returns the most recent price update in this contract without any recency checks.
/// This function is unsafe as the returned price update may be arbitrarily far in the past.
///
/// Users of this function should check the `publishTime` in the price to ensure that the returned price is
/// sufficiently recent for their application. If you are considering using this function, it may be
/// safer / easier to use either `getPrice` or `getPriceNoOlderThan`.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getPriceUnsafe(
bytes32 id
) external view returns (PythStructs.Price memory price);
/// @notice Returns the price that is no older than `age` seconds of the current time.
/// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in
/// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
/// recently.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getPriceNoOlderThan(
bytes32 id,
uint age
) external view returns (PythStructs.Price memory price);
/// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks.
/// @dev This function returns the same price as `getEmaPrice` in the case where the price is available.
/// However, if the price is not recent this function returns the latest available price.
///
/// The returned price can be from arbitrarily far in the past; this function makes no guarantees that
/// the returned price is recent or useful for any particular application.
///
/// Users of this function should check the `publishTime` in the price to ensure that the returned price is
/// sufficiently recent for their application. If you are considering using this function, it may be
/// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getEmaPriceUnsafe(
bytes32 id
) external view returns (PythStructs.Price memory price);
/// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds
/// of the current time.
/// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in
/// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
/// recently.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getEmaPriceNoOlderThan(
bytes32 id,
uint age
) external view returns (PythStructs.Price memory price);
/// @notice Update price feeds with given update messages.
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
/// `getUpdateFee` with the length of the `updateData` array.
/// Prices will be updated if they are more recent than the current stored prices.
/// The call will succeed even if the update is not the most recent.
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.
/// @param updateData Array of price update data.
function updatePriceFeeds(bytes[] calldata updateData) external payable;
/// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is
/// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the
/// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`.
///
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
/// `getUpdateFee` with the length of the `updateData` array.
///
/// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime
/// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have
/// a newer or equal publish time than the given publish time, it will reject the transaction to save gas.
/// Otherwise, it calls updatePriceFeeds method to update the prices.
///
/// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid.
/// @param updateData Array of price update data.
/// @param priceIds Array of price ids.
/// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`
function updatePriceFeedsIfNecessary(
bytes[] calldata updateData,
bytes32[] calldata priceIds,
uint64[] calldata publishTimes
) external payable;
/// @notice Returns the required fee to update an array of price updates.
/// @param updateData Array of price update data.
/// @return feeAmount The required fee in Wei.
function getUpdateFee(
bytes[] calldata updateData
) external view returns (uint feeAmount);
/// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published
/// within `minPublishTime` and `maxPublishTime`.
///
/// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price;
/// otherwise, please consider using `updatePriceFeeds`. This method may store the price updates on-chain, if they
/// are more recent than the current stored prices.
///
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
/// `getUpdateFee` with the length of the `updateData` array.
///
///
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is
/// no update for any of the given `priceIds` within the given time range.
/// @param updateData Array of price update data.
/// @param priceIds Array of price ids.
/// @param minPublishTime minimum acceptable publishTime for the given `priceIds`.
/// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`.
/// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order).
function parsePriceFeedUpdates(
bytes[] calldata updateData,
bytes32[] calldata priceIds,
uint64 minPublishTime,
uint64 maxPublishTime
) external payable returns (PythStructs.PriceFeed[] memory priceFeeds);
/// @notice Similar to `parsePriceFeedUpdates` but ensures the updates returned are
/// the first updates published in minPublishTime. That is, if there are multiple updates for a given timestamp,
/// this method will return the first update. This method may store the price updates on-chain, if they
/// are more recent than the current stored prices.
///
///
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is
/// no update for any of the given `priceIds` within the given time range and uniqueness condition.
/// @param updateData Array of price update data.
/// @param priceIds Array of price ids.
/// @param minPublishTime minimum acceptable publishTime for the given `priceIds`.
/// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`.
/// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order).
function parsePriceFeedUpdatesUnique(
bytes[] calldata updateData,
bytes32[] calldata priceIds,
uint64 minPublishTime,
uint64 maxPublishTime
) external payable returns (PythStructs.PriceFeed[] memory priceFeeds);
}
IPythEvents.sol 18 lines
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @title IPythEvents contains the events that Pyth contract emits.
/// @dev This interface can be used for listening to the updates for off-chain and testing purposes.
interface IPythEvents {
/// @dev Emitted when the price feed with `id` has received a fresh update.
/// @param id The Pyth Price Feed ID.
/// @param publishTime Publish time of the given price update.
/// @param price Price of the given price update.
/// @param conf Confidence interval of the given price update.
event PriceFeedUpdate(
bytes32 indexed id,
uint64 publishTime,
int64 price,
uint64 conf
);
}
PythStructs.sol 33 lines
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
contract PythStructs {
// A price with a degree of uncertainty, represented as a price +- a confidence interval.
//
// The confidence interval roughly corresponds to the standard error of a normal distribution.
// Both the price and confidence are stored in a fixed-point numeric representation,
// `x * (10^expo)`, where `expo` is the exponent.
//
// Please refer to the documentation at https://docs.pyth.network/documentation/pythnet-price-feeds/best-practices for how
// to how this price safely.
struct Price {
// Price
int64 price;
// Confidence interval around the price
uint64 conf;
// Price exponent
int32 expo;
// Unix timestamp describing when the price was published
uint publishTime;
}
// PriceFeed represents a current aggregate price from pyth publisher feeds.
struct PriceFeed {
// The price ID.
bytes32 id;
// Latest available price
Price price;
// Latest available exponentially-weighted moving average price
Price emaPrice;
}
}
PythAggregatorV3.sol 98 lines
// SPDX-License-Identifier: GPL-3.0
// ███████╗███████╗██████╗ ██████╗
// ╚══███╔╝██╔════╝██╔══██╗██╔═══██╗
// ███╔╝ █████╗ ██████╔╝██║ ██║
// ███╔╝ ██╔══╝ ██╔══██╗██║ ██║
// ███████╗███████╗██║ ██║╚██████╔╝
// ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝
// Website: https://zerolend.xyz
// Discord: https://discord.gg/zerolend
// Twitter: https://twitter.com/zerolendxyz
pragma solidity ^0.8.12;
import {PythStructs} from "@pythnetwork/pyth-sdk-solidity/PythStructs.sol";
import {IPyth} from "@pythnetwork/pyth-sdk-solidity/IPyth.sol";
/**
* @title A port of a chainlink aggregator powered by pyth network feeds
* @author Deadshot Ryker
* @notice This does not store any roundId information on-chain. Please review the code before using this implementation.
*/
contract PythAggregatorV3 {
bytes32 public priceId;
IPyth public pyth;
constructor(address _pyth, bytes32 _priceId) {
priceId = _priceId;
pyth = IPyth(_pyth);
}
function updateFeeds(bytes[] calldata priceUpdateData) public payable {
// Update the prices to the latest available values and pay the required fee for it. The `priceUpdateData` data
// should be retrieved from our off-chain Price Service API using the `pyth-evm-js` package.
// See section "How Pyth Works on EVM Chains" below for more information.
uint256 fee = pyth.getUpdateFee(priceUpdateData);
pyth.updatePriceFeeds{value: fee}(priceUpdateData);
// refund remaining eth
payable(msg.sender).call{value: address(this).balance}("");
}
function decimals() public view virtual returns (uint8) {
PythStructs.Price memory price = pyth.getPriceUnsafe(priceId);
return uint8(-1 * int8(price.expo));
}
function description() public pure returns (string memory) {
return "A port of a chainlink aggregator powered by pyth network feeds";
}
function version() public pure returns (uint256) {
return 1;
}
function latestAnswer() public view virtual returns (int256) {
PythStructs.Price memory price = pyth.getPriceNoOlderThan(priceId, 1 days);
return int256(price.price);
}
function latestTimestamp() public view returns (uint256) {
PythStructs.Price memory price = pyth.getPriceNoOlderThan(priceId, 1 days);
return price.publishTime;
}
function latestRound() public view returns (uint256) {
// use timestamp as the round id
return latestTimestamp();
}
function getAnswer(uint256) public view returns (int256) {
return latestAnswer();
}
function getTimestamp(uint256) external view returns (uint256) {
return latestTimestamp();
}
function getRoundData(uint80 _roundId)
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
{
PythStructs.Price memory price = pyth.getPriceUnsafe(priceId);
return (_roundId, int256(price.price), price.publishTime, price.publishTime, _roundId);
}
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
{
PythStructs.Price memory price = pyth.getPriceUnsafe(priceId);
roundId = uint80(price.publishTime);
return (roundId, int256(price.price), price.publishTime, price.publishTime, roundId);
}
}
Read Contract
decimals 0x313ce567 → uint8
description 0x7284e416 → string
getAnswer 0xb5ab58dc → int256
getRoundData 0x9a6fc8f5 → uint80, int256, uint256, uint256, uint80
getTimestamp 0xb633620c → uint256
latestAnswer 0x50d25bcd → int256
latestRound 0x668a0f02 → uint256
latestRoundData 0xfeaf968c → uint80, int256, uint256, uint256, uint80
latestTimestamp 0x8205bf6a → uint256
priceId 0x31189334 → bytes32
pyth 0xf98d06f0 → address
version 0x54fd4d50 → uint256
Write Contract 1 functions
These functions modify contract state and require a wallet transaction to execute.
updateFeeds 0xbc36c0a9
bytes[] priceUpdateData
Recent Transactions
No transactions found for this address