PythStructs.sol 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. struct TwapPriceFeed {
  32. // The price ID.
  33. bytes32 id;
  34. // Start time of the TWAP
  35. uint startTime;
  36. // End time of the TWAP
  37. uint endTime;
  38. // TWAP price
  39. Price twap;
  40. // Down slot ratio
  41. uint32 downSlotRatio;
  42. }
  43. }