SchedulerStructs.sol 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-License-Identifier: Apache 2
  2. pragma solidity ^0.8.0;
  3. /// @title SchedulerStructs
  4. /// @notice Contains data structures used by the Pyth Pulse protocol
  5. contract SchedulerStructs {
  6. /// @notice Parameters defining a Pulse subscription
  7. struct SubscriptionParams {
  8. bytes32[] priceIds; // Array of Pyth price feed IDs to subscribe to
  9. address[] readerWhitelist; // Optional array of addresses allowed to read prices
  10. bool whitelistEnabled; // Whether to enforce whitelist or allow anyone to read
  11. bool isActive; // Whether the subscription is active
  12. bool isPermanent; // Whether the subscription can be updated
  13. UpdateCriteria updateCriteria; // When to update the price feeds
  14. }
  15. /// @notice Status information for a Pulse subscription
  16. struct SubscriptionStatus {
  17. uint256 priceLastUpdatedAt; // Timestamp of the last update. All feeds in the subscription are updated together.
  18. uint256 balanceInWei; // Balance that will be used to fund the subscription's upkeep.
  19. uint256 totalUpdates; // Tracks update count across all feeds in the subscription (increments by number of feeds per update)
  20. uint256 totalSpent; // Counter of total fees paid for subscription upkeep in wei.
  21. }
  22. /// @notice Criteria for when price feeds should be updated
  23. struct UpdateCriteria {
  24. bool updateOnHeartbeat; // Should update based on time elapsed
  25. uint32 heartbeatSeconds; // Time interval for heartbeat updates
  26. bool updateOnDeviation; // Should update based on price deviation
  27. uint32 deviationThresholdBps; // Price deviation threshold in basis points
  28. }
  29. }