PythStructs.sol 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-License-Identifier: Apache-2.0
  2. pragma solidity ^0.8.0;
  3. contract PythStructs {
  4. // A price with a degree of uncertainty, represented as a price +- a confidence interval.
  5. //
  6. // The confidence interval roughly corresponds to the standard error of a normal distribution.
  7. // Both the price and confidence are stored in a fixed-point numeric representation,
  8. // `x * (10^expo)`, where `expo` is the exponent.
  9. //
  10. // Please refer to the documentation at https://docs.pyth.network/documentation/pythnet-price-feeds/best-practices for how
  11. // to how this price safely.
  12. struct Price {
  13. // Price
  14. int64 price;
  15. // Confidence interval around the price
  16. uint64 conf;
  17. // Price exponent
  18. int32 expo;
  19. // Unix timestamp describing when the price was published
  20. uint publishTime;
  21. }
  22. // PriceFeed represents a current aggregate price from pyth publisher feeds.
  23. struct PriceFeed {
  24. // The price ID.
  25. bytes32 id;
  26. // Latest available price
  27. Price price;
  28. // Latest available exponentially-weighted moving average price
  29. Price emaPrice;
  30. }
  31. }