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