state.proto 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. syntax = "proto3";
  2. package lazer;
  3. import "google/protobuf/duration.proto";
  4. import "google/protobuf/timestamp.proto";
  5. // All optional fields should always be set unless documented otherwise.
  6. // State of a Pyth Lazer shard.
  7. //
  8. // The state is shared across all Pyth Lazer aggregators that process this shard.
  9. // All aggregators should observe the same state at any `last_sequence_no`.
  10. // The state contains all the information necessary for processing the updates.
  11. // The aggregators cannot rely on any external data, except the state and the update sequence.
  12. // A snapshot of the state includes the serialized `State` value as the payload.
  13. message State {
  14. // [required] ID of this shard. Each state value only accounts for data of a particular shard.
  15. optional uint32 shard_id = 1;
  16. // [required] sequence_no of the last update applied to the state.
  17. optional uint64 last_sequence_no = 2;
  18. // [required] Timestamp of the last update provided by Kafka/Nats.
  19. // If no updates were applied, contains the timestamp of genesis snapshot creation time.
  20. optional google.protobuf.Timestamp last_timestamp = 3;
  21. // [required] Shard name (only for debug/monitoring/management purposes). Must be unique.
  22. optional string shard_name = 4;
  23. // [required] Minimal aggregation rate allowed in this shard.
  24. optional google.protobuf.Duration min_rate = 5;
  25. // List of feeds.
  26. repeated Feed feeds = 7;
  27. // List of publishers.
  28. repeated Publisher publishers = 8;
  29. // TODO: governance state (pubkey, last sequence no)
  30. }
  31. // An item of the state describing a publisher.
  32. message Publisher {
  33. // [required] Publisher ID. Restricted to uint16.
  34. optional uint32 publisher_id = 1;
  35. // [required] Publisher name (only for debug/monitoring/management purposes). Must be unique.
  36. optional string name = 2;
  37. // Public keys used to sign publisher update transactions.
  38. repeated bytes public_keys = 3;
  39. // [required] If true, the publisher is active, i.e. it's allowed to publish updates.
  40. optional bool is_active = 4;
  41. }
  42. // Static data for a feed.
  43. message FeedMetadata {
  44. // [required] ID of the price feed.
  45. optional uint32 price_feed_id = 1;
  46. // [required] Feed name.
  47. optional string name = 2;
  48. // [required] Feed symbol.
  49. optional string symbol = 3;
  50. // [required] Feed description.
  51. optional string description = 4;
  52. // [required] Feed asset type.
  53. optional string asset_type = 5;
  54. // [required] Exponent applied to all price and rate values for this feed.
  55. // Actual value is `mantissa * 10 ^ exponent`.
  56. // Restricted to int16.
  57. optional sint32 exponent = 6;
  58. // [optional] CoinMarketCap ID. Can be absent if there is no CoinMarketCap ID for this symbol.
  59. optional uint32 cmc_id = 7;
  60. // [optional] Funding rate interval. Only present for funding rate feeds.
  61. optional google.protobuf.Duration funding_rate_interval = 8;
  62. // [required] Minimal number of publisher prices required to produce an aggregate.
  63. optional uint32 min_publishers = 9;
  64. // [required] Minimal rate of aggregation performed by the aggregator for this feed.
  65. // Cannot be lower than the shard's top level `State.min_rate`.
  66. optional google.protobuf.Duration min_rate = 10;
  67. // [required] Time after which the publisher update is discarded.
  68. optional google.protobuf.Duration expiry_time = 11;
  69. // [required] If true, the feed is visible to the consumers. This can be used to prepare and verify
  70. // new feeds before releasing them. This can also be used to migrate a feed from
  71. // one shard to another. If a feed is present in
  72. // multiple shards, it must only be active in one of them at each time.
  73. // To enforce this, `pending_activation` and `pending_deactivation` fields
  74. // can be used to deactivate a feed in one shard and activate it in another shard
  75. // at the same instant.
  76. optional bool is_activated = 12;
  77. // [optional] ID of the corresponding price feed in Hermes (Pythnet).
  78. optional string hermes_id = 13;
  79. // [optional] Quote currency of the asset.
  80. optional string quote_currency = 14;
  81. // [optional] Market schedule in Pythnet format.
  82. // If absent, the default schedule is used (market is always open).
  83. optional string market_schedule = 15;
  84. }
  85. // An item of the state describing a feed.
  86. message Feed {
  87. optional FeedMetadata metadata = 1;
  88. // [optional] If present, the aggregator will activate the feed at the specified instant.
  89. optional google.protobuf.Timestamp pending_activation = 2;
  90. // [optional] If present, the aggregator will deactivate the feed at the specified instant.
  91. optional google.protobuf.Timestamp pending_deactivation = 3;
  92. // Additional state per publisher.
  93. // If an eligible publisher is not listed here, the corresponding state should be considered empty.
  94. repeated FeedPublisherState per_publisher = 4;
  95. // TODO: list of permissioned publisher IDs.
  96. }
  97. // A part of the feed state related to a particular publisher.
  98. message FeedPublisherState {
  99. // [required] Publisher ID. Restricted to uint16.
  100. optional uint32 publisher_id = 1;
  101. // [optional] Timestamp of the last update received from this publisher to this feed.
  102. // This timestamp is provided by Nats/Kafka, not by publisher.
  103. // Can be absent if no update was ever received or if the last update was deemed no longer relevant.
  104. optional google.protobuf.Timestamp last_update_timestamp = 2;
  105. // [optional] Publisher timestamp of the last update received from this publisher to this feed.
  106. // This timestamp is provided by publisher.
  107. // Can be absent if no update was ever received or if the last update was deemed no longer relevant.
  108. optional google.protobuf.Timestamp last_publisher_timestamp = 3;
  109. // [optional] Data of the last update received from this publisher to this feed.
  110. // Can be absent if no update was ever received or if the last update was deemed no longer relevant.
  111. optional FeedData last_feed_data = 4;
  112. }
  113. // Data provided by a publisher for a certain feed.
  114. message FeedData {
  115. // [required] Timestamp provided by the source of data that the publisher uses (e.g. an exchange).
  116. // If no such timestamp is available, it should be set to the same value as `publisher_timestamp`.
  117. optional google.protobuf.Timestamp source_timestamp = 1;
  118. // [required] Timestamp of the publisher.
  119. optional google.protobuf.Timestamp publisher_timestamp = 2;
  120. // [optional] Best executable price. Can be absent if no data is available. Never present for funding rate feeds.
  121. optional int64 price = 3;
  122. // [optional] Best bid price. Can be absent if no data is available. Never present for funding rate feeds.
  123. optional int64 best_bid_price = 4;
  124. // [optional] Best ask price. Can be absent if no data is available. Never present for funding rate feeds.
  125. optional int64 best_ask_price = 5;
  126. // [optional] Funding rate. Can be absent if no data is available. Can only be present for funding rate feeds.
  127. optional int64 funding_rate = 6;
  128. }