adityapk00 / lightwalletd

LightwalletD is the light wallet client server for Zcash
MIT License
19 stars 19 forks source link

Binance is returning wonky USDC prices; use BUSD or USDT #12

Open defuse opened 1 year ago

defuse commented 1 year ago

I noticed in lightwalletd's logs that it was excluding the price from binance because it was 55.8 whereas the actual price of ZEC was around 42.7. Their APIs for USDC prices seem to be broken, not returning the correct price for all the coins I tried.

I was able to get the correct price using any of https://api.binance.com/api/v3/ticker/price?symbol=ZECBUSD or https://api.binance.com/api/v3/ticker/price?symbol=ZECUSDT, https://api.binance.com/api/v3/avgPrice?symbol=ZECBUSD, https://api.binance.com/api/v3/avgPrice?symbol=ZECUSDT.

I'm not sure what's going on with the USDC prices over at binance, but you might want to change the Binance URL in lightwalletd to one of the above.

defuse commented 1 year ago

Oh, it's probably because Binance stopped supporting USDC: https://techcrunch.com/2022/09/05/binance-issuer-of-stablecoin-busd-to-discontinue-support-for-usdc-usdp-and-tusd/

So, we probably want to use https://api.binance.com/api/v3/avgPrice?symbol=ZECBUSD going forward.

LarryRuane commented 1 year ago

That URL doesn't work for me, at least at this moment:

$ curl -s https://api.binance.com/api/v3/avgPrice?symbol=ZECBUSD
{
  "code": 0,
  "msg": "Service unavailable from a restricted location according to 'b. Eligibility' in https://www.binance.com/en/terms. Please contact customer service if you believe you received this message in error."
$

The old URL gives the same error. Does this work for you? Maybe there's something wrong in my setup?

defuse commented 1 year ago

It works for me when I request it from Canada. However when I turn on a VPN to the USA, I get the same error. :disappointed: I get the same error when I request the URL that's currently in lightwalletd, too, so it might still be worth changing it.

defuse commented 1 year ago

https://api.binance.us/api/v3/avgPrice?symbol=ZECUSDT (note .us instead of .com) seems to work from USA, Canada, Hong Kong, Germany, .... hopefully that one isn't geo-restricted.

LarryRuane commented 1 year ago

Yes, replacing .com with .us works for me too. (BTW, I think you have a typo in your comment above, ZECBUSD, https://github.com/adityapk00/lightwalletd/issues/12#issuecomment-1428584662)

Should we include both the .com and .us endpoints? It's okay if one of them fails. PR #354 currently has 4 price providers and requires any combination of 3 of them to respond. If we now have 5, we could still require any 3 of them to respond.

When should we actually merge #354, by the way?