lbry-sdk icon indicating copy to clipboard operation
lbry-sdk copied to clipboard

New method to get the USD/LBC exchange rate

Open belikor opened this issue 2 years ago • 0 comments

Discussing on Discord we think that maybe there should be a way of getting the USD/LBC exchange rate directly from lbrynet.

At the moment the SDK gets this information and uses it internally with the ExchangeRateManager class which connects to various exchanges. It uses this to estimate the price in USD of content that has a price at publication time.

https://github.com/lbryio/lbry-sdk/blob/442326f1d8fc8d9063c783c6d98e948758f130b5/lbry/extras/daemon/exchange_rate_manager.py#L194-L240

However, the exchange rate is not exposed in other parts of lbrynet. We could use the exchange rate in other applications if this information was exposed.

A place to put the rate would be the output of lbrynet status. For example:

lbrynet status
{
  ...
  "wallet_server_payments": {
    "max_fee": "0.0",
    "running": false
  },
  "USD_per_LBC": {
    "average": "0.045"
  }
}

Another possibility would be to create a new command that just returns this information. We could return the average rate but also the rate from a single source. For example:

lbrynet exchange list
{
  "USD_per_LBC": {
    "average": "0.045",
    "CoinEx": "0.04451",
    "Hotbit": "0.046",
    "Bittrex": "0.455"
  }
}
lbrynet exchange list --source=CoinEx
{
  "USD_per_LBC": {
    "CoinEx": "0.04451"
  }
}

In the source code there is a list of exchanges defined by default, but there could be a way of adding more exchanges, and saving these options in the settings:

lbrynet settings set exchange_source '(Fake, https://fake.exchange)'

belikor avatar Dec 08 '21 22:12 belikor