classic-terra / oracle-feeder

Oracle Feeder Daemon
Apache License 2.0
6 stars 7 forks source link

New price-server has only one crypto provider that is working #24

Open aeuser999 opened 1 year ago

aeuser999 commented 1 year ago

As was noticed by a few validators, only one crypto provider is reporting back CoinGecko.

I thought maybe with the new endpoint that was shared it would be able to work with Binance. However, I tested it, and here is what I found. The alternative endpoint(s) do work, but it looks like it may only translate the price if it has a direct pair to USD. Binance does not have a LUNCUSD pair. The way the older oracle handled this was with this LunaProvider class here . When TFL repurposed the oracle repository for their purposes, they removed it. It appears the way it worked was to use the pairs provided in the default.js lunaProvider json object to translate if needed using the LunaProvider class (so something like LUNA v1 > USDC > USD)(where there was not a USD pair directly available to be defined).

I think the removal of the LunaProvider class is what may have caused an issue for the other crypto providers such as Kraken (which does have a direct LUNA/USD pair [LUNA v2 is called LUNA2/USD in their exchange]). By reworking it to add the LunaProvider class back in, it may save some time and work?

But, however the L1 team chooses to best handle this, right now CoinGecko is the only crypto provider actually working for the USD translation, and I am wondering if we can get that fixed since it is a single point of failure.

Here is the test I used to test this:

Thank you so much for looking into this (and thank you also for the work you have done to strengthen the fiat side with the extra SDR/XDR source, and making sure the other fiat SDR/XDR sources work).

nghuyenthevinh2000 commented 1 year ago

thanks you so much for this, I will investigate this further

aeuser999 commented 1 year ago

Hi @nghuyenthevinh2000 ,

Just passing along some testing that another user did, using the above test procedure in the description of the issue (they are in a region that the Binance api does work).

The results that both this person (within the region Binance is available and using the api.binance.com in the code), are also the same results as I received using the endpoints that work out-of-region (I tried with both data.binance.com and also data-api.binance.vision endpoints in the Binance.ts crypto provider code) - that it does not return back the crypto pricing (only the fiat pricing).

Whether it was the endpoints that work out-of-region here (ie. data.binance.com or data-api.binance.vision ), or the original endpoint in the oracle price-server code for Binance that has region restrictions (ie. api.binance.com ), the results are the same in both scenarios of testing for the Binance crypto provider from the price-server using the test outlined in the description.

The results are that the Binance crypto provider in the price-server does not return back any crypto pricing (it only returns back the fiat pricing but without also returning back the crypto pricing).

Here are those results from http://localhost:8532/latest :

{"created_at":"2023-09-13T20:14:32.611Z","prices":[{"denom":"SDR","price":"1.32696038"},{"denom":"KRW","price":"0.00075385"},{"denom":"MNT","price":"0.00029008"},{"denom":"EUR","price":"1.07568174"},{"denom":"CNY","price":"0.13745126"},{"denom":"JPY","price":"0.00679028"},{"denom":"GBP","price":"1.24829452"},{"denom":"INR","price":"0.01207233"},{"denom":"CAD","price":"0.73822640"},{"denom":"CHF","price":"1.12230297"},{"denom":"HKD","price":"0.12787617"},{"denom":"AUD","price":"0.64128915"},{"denom":"SGD","price":"0.73530006"},{"denom":"THB","price":"0.02802529"},{"denom":"SEK","price":"0.09012188"},{"denom":"DKK","price":"0.14421484"},{"denom":"IDR","price":"0.00006513"},{"denom":"PHP","price":"0.01768003"},{"denom":"MYR","price":"0.21379317"},{"denom":"NOK","price":"0.09367463"},{"denom":"TWD","price":"0.03129096"}]}

I hope that helps a little bit, and that you have a great day today :)

inon-man commented 1 year ago

@aeuser999 Where does your oracle feeder geographically located at? I've published v3.3.1 release that includes fix(#23). Could you try this?

aeuser999 commented 1 year ago

Hi @inon-man ,

Thank you so much for doing that. I am outside of the Binance region. I will give it a try tomorrow evening and post back. Will also see if Bee from HX would be interested in testing as well.

Thank you again - I hope you are having a great day today :)

aeuser999 commented 1 year ago

Hi @inon-man ,

Just wanted to give you a status update:
I did want to let you know that I am testing. I did not realize until some testing with Bee @ HX over the weekend, where he pointed out that you were making translations in the PricesProvider.ts (either direct pricing of LUNA v1/USD or translated LUNA v1 > Intermediary > USD). I just missed that it was making them there in a dynamic manner.

The Binance changes did test out as coming through so far with the api endpoint change (however, since those pairs do not have a USD pair, they do not show up in the price-server results without a provider with a USD pair).

Which leads up to the reason I originally wrote this issue. Having only CoinGecko as the USD pair translation is a single point of failure. It really needs each of the CEX based crypto providers fixed to work.

I did find that Kraken has a direct LUNA/USD pair (that is how it is listed in their exchange, their is also a LUNA2/USD for Terra v2), Huobi (LUNA v1 to Stable Coins), and Kucoin ( LUNA v1 to Stable Coins). Bitfinex has Stable Coin to USD pairs (to help with that translation).

I did come up with a fix for the Kraken.ts and Bitfinex.ts (I think I should be able to share those tomorrow when I have some time to finish up my testing, and can push my test repo to a public repo on github - if helpful).

I hope you are doing well today :)

aeuser999 commented 1 year ago

Hi @inon-man ,

Ok, I updated (or confirmed) the following providers to work along with CoinGecko and Binance:

I worked from this default.js (paired it down to only the necessary coins):

Please feel free to use the code, and improve upon it. I have tested that it is working for each provider, and working with CoinGecko and Binance providers (using a test similar to the one in the description, as well as using the console.log() outputs that I put in each provider for testing [they are not indented to help them stand out for removal]). The https://github.com/aeuser999/test_oracle_feeder repo is the code I used to test with.

I hope that helps out, and that you are having a great day today :)