From 7dc8c3bb374ce98ff692f51ff8f6ac0febde98ad Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 13 Jun 2024 17:08:05 +0800 Subject: [PATCH 1/2] rm leaky log --- src/core/atomicdex/pages/qt.wallet.page.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/atomicdex/pages/qt.wallet.page.cpp b/src/core/atomicdex/pages/qt.wallet.page.cpp index 14b383dae8..74056aa5e2 100644 --- a/src/core/atomicdex/pages/qt.wallet.page.cpp +++ b/src/core/atomicdex/pages/qt.wallet.page.cpp @@ -735,7 +735,7 @@ namespace atomic_dex nlohmann::json json_data = mm2::template_request("withdraw", true); mm2::to_json(json_data, withdraw_req); - SPDLOG_DEBUG("final json: {}", json_data.dump(4)); + batch.push_back(json_data); std::string amount_std = amount.toStdString(); From dd552de662225b2471f088a37aa3938b52141369 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 13 Jun 2024 18:34:08 +0800 Subject: [PATCH 2/2] fix missing rates calc --- .../atomicdex/models/qt.portfolio.model.cpp | 2 ++ .../services/price/global.provider.cpp | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/core/atomicdex/models/qt.portfolio.model.cpp b/src/core/atomicdex/models/qt.portfolio.model.cpp index 55b6557f2f..6c0b8bc922 100644 --- a/src/core/atomicdex/models/qt.portfolio.model.cpp +++ b/src/core/atomicdex/models/qt.portfolio.model.cpp @@ -109,6 +109,8 @@ namespace atomic_dex bool portfolio_model::update_activation_status() { + // This feels a bit heavy handed. There should be a better way to do this. + // Function may be unused. const auto& mm2_system = this->m_system_manager.get_system(); const auto coins = this->m_system_manager.get_system().get_global_cfg()->get_enabled_coins(); diff --git a/src/core/atomicdex/services/price/global.provider.cpp b/src/core/atomicdex/services/price/global.provider.cpp index d9d84a0852..74aefc3d1a 100644 --- a/src/core/atomicdex/services/price/global.provider.cpp +++ b/src/core/atomicdex/services/price/global.provider.cpp @@ -99,15 +99,18 @@ namespace atomic_dex global_price_service::refresh_other_coins_rates( const std::string& quote_id, const std::string& ticker, bool with_update_providers, std::atomic_uint16_t nb_try) { - // nb_try += 1; - // TODO: Paprika price conversion removed, needs to be replaced - nb_try = 10; - SPDLOG_INFO("refresh_other_coins_rates - try {}", nb_try.load()); - if (nb_try == 10) + t_float_50 price = safe_float(get_rate_conversion("USD", ticker, true)); + if (price <= 0) { - SPDLOG_WARN("refresh other coins rates max try reached, skipping"); - return; + SPDLOG_ERROR("Price is 0 for ticker: {}", ticker); + this->m_coin_rate_providers[ticker] = "0.00"; } + else + { + t_float_50 rate = 1 / price; + this->m_coin_rate_providers[ticker] = rate.str(); + } + } global_price_service::global_price_service(entt::registry& registry, ag::ecs::system_manager& system_manager, atomic_dex::cfg& cfg) : @@ -140,14 +143,14 @@ namespace atomic_dex { if (fiat == utils::retrieve_main_ticker(ticker_in)) { - return "1"; + return "1.00"; } std::string ticker = utils::retrieve_main_ticker(ticker_in); try { //! FIXME: fix zatJum crash report, frontend QML try to retrieve price before program is even launched if (ticker.empty()) - return "0"; + return "0.00"; auto& provider = m_system_manager.get_system(); std::string current_price = provider.get_rate_conversion(ticker); @@ -182,7 +185,7 @@ namespace atomic_dex { if (current_price_f < 1.0) { - default_precision = 5; + default_precision = 8; } } //! Trick: If there conversion in a fixed representation is 0.00 then use a default precision to 2 without fixed ios flags