Skip to content

Extend BlockUpdates to include component tvl data #211

@louise-poole

Description

@louise-poole

Context

Knowing the TVL of a pool can be very useful for many of the consumers of Tycho data: it could be used to determine the stability of the spot price of the pool, to prioritise pools by liquidity, and much more.

Recently, streaming component tvl was added to to the tycho indexer (version 0.69.0). This update allows one to opt into getting tvl data on the tycho-client. The final step needed for this feature is to now also consume and expose tvl on tycho-simulation.

Note: requesting tvl data adds some start-up latency to the tycho stream. During this task one must keep in mind that not all users are interested in tvl and good performance is our highest priority. Therefore, we should only stream and consume tvl data if the user explicitly wants it.

Outline of required changes

  • Update the tycho dependencies to 0.69.0 or above.
  • Extend the ProtocolStreamBuilder to allow a user to set include_tvl to true. Make sure to document that this may increase start-up latency.
  • Extend the BlockUpdate struct to include tvl updates. It should be a hashmap of component_id to component_tvl: HashMap<String, f64>.
  • Update the decode function of the TychoStreamDecoder. It should now include extracting component_tvl data from the received FeedMessage. Tvl data is included in 2 places in the message: in snapshots (for new components) and in deltas (when updated for already-seen components). Collect all tvl changes from these two parts of the feed message and add them to the BlockUpdate message emitted at the end of the function.

Deliverables

  • All changes outlined above
  • Appropriate tests for the new decoder functionality

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions