From 4b70e957090722cccdcf7976c4a6ea70578231c7 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 6 Nov 2023 01:56:55 +0800 Subject: [PATCH] handle segwit volumes --- src/core/atomicdex/pages/qt.trading.page.cpp | 4 ++-- src/core/atomicdex/utilities/global.utilities.cpp | 13 +++++++++++-- src/core/atomicdex/utilities/global.utilities.hpp | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/core/atomicdex/pages/qt.trading.page.cpp b/src/core/atomicdex/pages/qt.trading.page.cpp index 120c26aa74..7c38c312e8 100644 --- a/src/core/atomicdex/pages/qt.trading.page.cpp +++ b/src/core/atomicdex/pages/qt.trading.page.cpp @@ -1374,8 +1374,8 @@ namespace atomic_dex { const auto& defi_stats_service = m_system_manager.get_system(); const auto* market_selector = get_market_pairs_mdl(); - const auto& base = market_selector->get_left_selected_coin().toStdString(); - const auto& rel = market_selector->get_right_selected_coin().toStdString(); + const auto& base = utils::retrieve_main_ticker(market_selector->get_left_selected_coin().toStdString(), true); + const auto& rel = utils::retrieve_main_ticker(market_selector->get_right_selected_coin().toStdString(), true); QString vol = QString::fromStdString(defi_stats_service.get_volume_24h(base, rel)); if (vol != m_pair_volume_24hr) diff --git a/src/core/atomicdex/utilities/global.utilities.cpp b/src/core/atomicdex/utilities/global.utilities.cpp index d17b2036d8..7531cb2c17 100644 --- a/src/core/atomicdex/utilities/global.utilities.cpp +++ b/src/core/atomicdex/utilities/global.utilities.cpp @@ -252,9 +252,18 @@ namespace atomic_dex::utils } std::string - retrieve_main_ticker(const std::string& ticker) + retrieve_main_ticker(const std::string& ticker, const bool segwit_only) { - if (const auto pos = ticker.find('-'); pos != std::string::npos) + auto pos = ticker.find('-'); + if (segwit_only) + { + if (ticker.find('-segwit') != std::string::npos) + { + return ticker.substr(0, pos); + } + return ticker; + } + if (pos != std::string::npos) { return ticker.substr(0, pos); } diff --git a/src/core/atomicdex/utilities/global.utilities.hpp b/src/core/atomicdex/utilities/global.utilities.hpp index 0f48d63790..4fbcd1fc2e 100644 --- a/src/core/atomicdex/utilities/global.utilities.hpp +++ b/src/core/atomicdex/utilities/global.utilities.hpp @@ -94,7 +94,7 @@ namespace atomic_dex::utils ENTT_API std::filesystem::path get_themes_path(); ENTT_API std::filesystem::path get_logo_path(); - std::string retrieve_main_ticker(const std::string& ticker); + std::string retrieve_main_ticker(const std::string& ticker, const bool segwit_only = false); void to_eth_checksum(std::string& address);