tellor-io / dataSpecs

Data specifications for oracle queries
17 stars 9 forks source link

Proposal to create ERC20SpotPrice query #7

Closed clamdad closed 2 years ago

clamdad commented 2 years ago

The following is a proposal for a new ERC20SpotPrice query.

This would be the first non-legacy token pricing query on TellorX. This document is meant to be a starting point. Discussion and feedback is welcome.

There is a corresponding pull request to implement this query type in the telliot-core:

tkernell commented 2 years ago

Is this always in terms of USD? Should we include a way to query prices in terms of other currencies/assets?

clamdad commented 2 years ago

Is this always in terms of USD? Should we include a way to query prices in terms of other currencies/assets?

Haha you're right, @tkernell! I used to have a currency parameter and I left it out.

For this proposal, I chose to identify the coin by contract address and chain_id. The advantage of this approach is that the query has no ambiguity.

My current inclination is to define more query types with less parameters as opposed having over-parameterized "do-it-all" query types.

So one solution is to simply rename this query type to ERC20SpotPriceUSD, then define another query type to handle token-to-token conversions. This would require an address and chain_id for both the coin and the currency paramters.

Another approach is to use ticker symbols to identify the coin and/or currency. ​The drawback is that symbols are not unique and we'd have to maintain a table of symbol definitions off-chain, which could eventually lead to conflicts/confusion.

tkernell commented 2 years ago

The contract address + chain id approach is definitely simple and unambiguous! I think renaming this query to ERC20SpotPriceUSD is a good solution since it clarifies what base currency is being requested, while keeping the simplicity of having just those two input arguments.

clamdad commented 2 years ago

Updated query description and used a slightly different approach. @tkernell @themandalore

themandalore commented 2 years ago

Looks good to me, the only I might change is just to drop the ERC20. ERC20 is a pretty broad category, but it could work with a lot of other standards (e.g. 721) and it also implies Ethereum (Binance is BIP20 for example, but it's the exact same thing). I also wonder if specifying the address is a bad idea. For instance when Tellor migrated, our address changed, but on centralized exchanges we were always just TRB and the price moved accordingly

clamdad commented 2 years ago

Thanks, @themandalore. A couple good points here.

I do like the idea of dropping ERC20 tag. I'd still like to qualify it with some tag that removes any ambiguity (or as much as possible. There's TokenSpotPrice, or maybe even EVMTokenSpotPrice to be more specific.

As for address vs. symbol, I still lean towards address to remove ambiguity, but I see your point. When the token address changed underneath the TRB symbol, it did cause caused quite a bit of confusion/churn in price feeds (e.g. uniswap/coingecko).
We also would not have to worry about the cases where the same symbol exists on multiple chains.