Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Price feeder limitations #792

Closed
4 tasks
Tracked by #1470
adamewozniak opened this issue Apr 11, 2022 · 8 comments
Closed
4 tasks
Tracked by #1470

Price feeder limitations #792

adamewozniak opened this issue Apr 11, 2022 · 8 comments
Assignees
Labels
C:Tools C:x/oracle T:Epic Larger epics for help with tracking

Comments

@adamewozniak
Copy link
Collaborator

Summary

Our price feeder has a few limitations that will affect our ability to support coins in the long term.

Problem Definition

Our price feeder is limited by :

  • The Three-Provider Rule

Currently for the price feeder to vote on an exchange rate, it has to have at least three providers. This is to avoid scenarios where one provider goes down and we become dependent on another, which might malfunction or have low enough volume to be manipulated. This creates a pretty big issue in the cosmos ecosystem, because there are quite a few tokens only on one or two exchanges, such as osmosis and juno.

So, the right number of providers to require for an exchange rate is the number of providers which list that rate.

  • Osmosis API limitations

Certain APIs have stale data, such as the osmosis API we're using, which consistently returns historical data from ~6-4 minutes ago. The price feeder only uses the most recent information, so it filters out any candles that occurred before a certain amount of time, currently set to three minutes. So, this rule keeps us further from supporting coins that are only on osmosis.

So really, the right number of providers to require for an exchange rate is the number of providers which list that rate, and has an up-to-date, low-latency API available.

Proposal

We should :

  1. Use an external data source (or sources) like coingecko to determine the amount of exchanges on which a pair is listed, and require that amount instead of the default of "3".
    a. Need to decide on what to do in the case that these APIs fail; do we require 3 as the default or are we more lenient to support those currencies which only have one or two exchange rates?

  2. Find a way to get more recent pricing data from osmosis. This would probably require us to run our own osmosis node & API instead of using imperator's.
    a. Still need to look into endpoint limitations. If this data isn't accessible, how do we determine what is an acceptable time period per provider?


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@adamewozniak
Copy link
Collaborator Author

adamewozniak commented Apr 13, 2022

Looking into solving the osmosis issue first since it blocks the most. We should aggregate the "Swap Exact Amount In" Transactions (e.g. this ATOM/ROWAN tx) and then use this to build an OHCL websocket.

The spot endpoint doesn't have support for volume, so we'll need to query transactions for both of these

Check out this repo for updates on development of this API :^)

@RafilxTenfen
Copy link
Contributor

About the proposal (1) We also could check on our own the number of exchanges on which a pair is listed using the providers GetAvailablePairs function ^^

@adamewozniak
Copy link
Collaborator Author

adamewozniak commented Sep 13, 2022

@RafilxTenfen yeah but this needs to also cover providers which we haven't implemented.
For example, we need to be aware of this scenario:

  1. a coin gets listed only on osmosis
  2. we hard-code a rule that allows a single provider for that coin, release the price feeder, and then get it on chain
  3. the coin gets listed somewhere else

We'd have to then implement the new provider as soon as possible, especially if it has high volume

@adamewozniak adamewozniak mentioned this issue Oct 4, 2022
14 tasks
@adamewozniak
Copy link
Collaborator Author

Imo this can be solved for blue chip assets in the short-term by adding osmosis support, since mexc & bitget have both been added as providers for the price feeder

@adamewozniak
Copy link
Collaborator Author

adamewozniak commented Oct 11, 2022

Adding @rbajollari onto this since he's working on using coingecko for # 1 🥳

@RafilxTenfen
Copy link
Contributor

  1. Use an external data source (or sources) like coingecko to determine the amount of exchanges on which a pair is listed, and require that amount instead of the default of "3".

Would be good to have at least 2 sources of exchanges... to avoid things like this again

@adamewozniak adamewozniak added the T:Epic Larger epics for help with tracking label Oct 19, 2022
@adamewozniak
Copy link
Collaborator Author

adamewozniak commented Oct 20, 2022

  1. Use an external data source (or sources) like coingecko to determine the amount of exchanges on which a pair is listed, and require that amount instead of the default of "3".

Would be good to have at least 2 sources of exchanges... to avoid things like this again

Agree, atm we mitigated this in #1496 by adding an override. That way the price feeders don't go down when coingecko goes down.

This can probably be closed after #1470 & we open a few tickets around cleanup like this ^

@adamewozniak
Copy link
Collaborator Author

Closing this out 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:Tools C:x/oracle T:Epic Larger epics for help with tracking
Projects
None yet
Development

No branches or pull requests

3 participants