SchedulerStructs.sol 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: Apache 2
  2. pragma solidity ^0.8.0;
  3. // This contract holds the Scheduler structs
  4. contract SchedulerStructs {
  5. /// Maximum number of price feeds per subscription
  6. uint8 public constant MAX_PRICE_IDS_PER_SUBSCRIPTION = 255;
  7. /// Maximum number of addresses in the reader whitelist
  8. uint8 public constant MAX_READER_WHITELIST_SIZE = 255;
  9. /// Maximum time in the past (relative to current block timestamp)
  10. /// for which a price update timestamp is considered valid
  11. /// when validating the update conditions.
  12. /// @dev Note: We don't use this when parsing update data from the Pyth contract
  13. /// because don't want to reject update data if it contains a price from a market
  14. /// that closed a few days ago, since it will contain a timestamp from the last
  15. /// trading period. We enforce this value ourselves against the maximum
  16. /// timestamp in the provided update data.
  17. uint64 public constant PAST_TIMESTAMP_MAX_VALIDITY_PERIOD = 1 hours;
  18. /// Maximum time in the future (relative to current block timestamp)
  19. /// for which a price update timestamp is considered valid
  20. uint64 public constant FUTURE_TIMESTAMP_MAX_VALIDITY_PERIOD = 10 seconds;
  21. /// Fixed gas overhead component used in keeper fee calculation.
  22. /// This is a rough estimate of the tx overhead for a keeper to call updatePriceFeeds.
  23. uint256 public constant GAS_OVERHEAD = 30000;
  24. struct SubscriptionParams {
  25. bytes32[] priceIds;
  26. address[] readerWhitelist;
  27. bool whitelistEnabled;
  28. bool isActive;
  29. bool isPermanent;
  30. UpdateCriteria updateCriteria;
  31. }
  32. struct SubscriptionStatus {
  33. uint256 priceLastUpdatedAt;
  34. uint256 balanceInWei;
  35. uint256 totalUpdates;
  36. uint256 totalSpent;
  37. }
  38. struct UpdateCriteria {
  39. bool updateOnHeartbeat;
  40. uint32 heartbeatSeconds;
  41. bool updateOnDeviation;
  42. uint32 deviationThresholdBps;
  43. }
  44. }