The hero's "24H Vol" showed CoinGecko's cross-exchange aggregate even after the chart/price went per-venue. Capture the per-exchange converted_volume.usd from the tickers (previously discarded, alongside converted_last) and show the SELECTED exchange's own 24h volume; fall back to the aggregate when unknown. Market cap stays aggregate (it's coin-wide, not per-venue). This is a big real difference — e.g. Ourbit ~$14.3K vs NonKYC ~$253 for DRGX/USDT — so the header now reflects the venue you're actually looking at. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
// DragonX Wallet - ImGui Edition
|
|
// Copyright 2024-2026 The Hush Developers
|
|
// Released under the GPLv3
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace dragonx {
|
|
namespace data {
|
|
|
|
/**
|
|
* @brief A single trading pair on an exchange (e.g. DRGX/BTC)
|
|
*/
|
|
struct ExchangePair {
|
|
std::string base; ///< e.g. "DRGX"
|
|
std::string quote; ///< e.g. "BTC"
|
|
std::string displayName; ///< e.g. "DRGX/BTC"
|
|
std::string tradeUrl; ///< Link to the exchange pair page
|
|
std::string identifier; ///< CoinGecko exchange id (e.g. "ourbit", "nonkyc_io") — keys the candle adapter
|
|
double lastUsd = 0.0; ///< This venue's current price in USD (CoinGecko converted_last.usd); 0 if unknown
|
|
double volumeUsd = 0.0; ///< This venue's 24h volume in USD (CoinGecko converted_volume.usd); 0 if unknown
|
|
};
|
|
|
|
/**
|
|
* @brief Metadata for a supported exchange
|
|
*/
|
|
struct ExchangeInfo {
|
|
std::string name; ///< e.g. "TradeOgre"
|
|
std::string baseUrl; ///< e.g. "https://tradeogre.com"
|
|
std::vector<ExchangePair> pairs;
|
|
};
|
|
|
|
/**
|
|
* @brief Returns the static registry of supported exchanges + pairs.
|
|
* Used as the offline fallback / seed when the live CoinGecko list is unavailable.
|
|
*/
|
|
const std::vector<ExchangeInfo>& getExchangeRegistry();
|
|
|
|
/**
|
|
* @brief Parse a CoinGecko /coins/{id}/tickers JSON body into the exchange registry.
|
|
*
|
|
* Groups tickers by exchange (market.name), preserving first-seen order, into
|
|
* ExchangeInfo entries (each pair carries base/target/displayName/trade_url). Returns
|
|
* an empty vector on parse failure or when no usable tickers are present. Pure (no I/O).
|
|
*/
|
|
std::vector<ExchangeInfo> parseCoinGeckoTickers(const std::string& json);
|
|
|
|
} // namespace data
|
|
} // namespace dragonx
|