KomodoPlatform / komodo-wallet-mobile

KomodoWallet Mobile codebase
https://komodoplatform.com
MIT License
21 stars 33 forks source link

[FR]: Show 24hr trade volume for pairs #79

Open smk762 opened 11 months ago

smk762 commented 11 months ago

Is your feature request related to a problem? Please describe. As part of the CoinGecko integration, we've been asked to add 24hr volume for pairs in our apps.

Describe your solution This data is available from https://defi-stats.komodo.earth/api/v3/gecko/tickers under volume_usd_24hr in the format below:

{
  "last_update": "1698305405",
  "pairs_count": "216",
  "swaps_count": "115",
  "combined_volume_usd": "3505.2077285338",
  "combined_liquidity_usd": "196344.5936695343",
  "data": {
    {
      "ticker_id": "KMD_DGB",
      "base_currency": "KMD",
      "target_currency": "DGB",
      "last_price": "31.0496050726",
      "last_trade": "1698297585",
      "trades_24hr": "1",
      "base_volume": "79.8180757000",
      "target_volume": "2478.3197281416",
      "bid": "31.3141610524",
      "ask": "32.2530298322",
      "high": "31.0496050726",
      "low": "31.0496050726",
      "volume_usd_24hr": "36.3250598387",
      "liquidity_in_usd": "4562.5344966628"
    },
    ....
}

Alternatively, the data is also available in a different format at https://defi-stats.komodo.earth/api/v3/tickers/summary for convenience

{
  "last_update": "1698305405",
  "pairs_count": "216",
  "swaps_count": "115",
  "combined_volume_usd": "3505.2077285338",
  "combined_liquidity_usd": "196344.5936695343",
  "data": {
    "KMD_DGB": {
      "base_currency": "KMD",
      "target_currency": "DGB",
      "last_price": "31.0496050726",
      "last_trade": "1698297585",
      "trades_24hr": "1",
      "base_volume": "79.8180757000",
      "target_volume": "2478.3197281416",
      "bid": "31.1210043124",
      "ask": "32.1988434824",
      "high": "31.0496050726",
      "low": "31.0496050726",
      "volume_usd_24hr": "36.6396291667",
      "liquidity_in_usd": "4573.7825261773"
    },
    ...
}

This data contains all pairs traded in the last 7 days, along with summary data for trades done in the last 24 hours. I'd suggest that where a ticker is not within the response that it default to a zero value.

Describe alternatives you've considered In future we might be able to use the same stats api to show network trades history as is visible in some cex dashboards, for example on the right in the image below. image

Additional context I've begun an implementation on legacy desktop for this, and will add screenshots in this issue once ready.