From 6a19c92abbc8125afd2017c7ac1249ff42537581 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 28 Mar 2024 16:57:55 +0800 Subject: [PATCH 01/26] rm paprika api services --- .../assets/languages/atomic_defi_de.ts | 72 +++-- .../assets/languages/atomic_defi_en.ts | 64 +++-- .../assets/languages/atomic_defi_es.ts | 68 +++-- .../assets/languages/atomic_defi_fr.ts | 72 +++-- .../assets/languages/atomic_defi_ru.ts | 72 +++-- .../assets/languages/atomic_defi_tr.ts | 72 +++-- src/app/app.cpp | 6 - .../atomicdex/api/coinpaprika/coinpaprika.cpp | 133 --------- .../atomicdex/api/coinpaprika/coinpaprika.hpp | 139 ---------- src/core/atomicdex/config/app.cfg.cpp | 6 +- .../internet/internet.checker.service.cpp | 3 +- .../coinpaprika/coinpaprika.provider.cpp | 259 ------------------ .../coinpaprika/coinpaprika.provider.hpp | 122 --------- .../atomicdex/services/price/defi.stats.cpp | 3 +- .../services/price/global.provider.cpp | 55 +--- .../price/orderbook.scanner.service.cpp | 6 +- src/core/atomicdex/utilities/safe.float.cpp | 2 +- 17 files changed, 270 insertions(+), 884 deletions(-) delete mode 100644 src/core/atomicdex/api/coinpaprika/coinpaprika.cpp delete mode 100644 src/core/atomicdex/api/coinpaprika/coinpaprika.hpp delete mode 100644 src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.cpp delete mode 100644 src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp diff --git a/atomic_defi_design/assets/languages/atomic_defi_de.ts b/atomic_defi_design/assets/languages/atomic_defi_de.ts index 0348200972..20b4136a5b 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_de.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_de.ts @@ -516,17 +516,17 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 Chart - - Loading market data - Laden von Marktdaten + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1956,11 +1956,6 @@ They will be removed from the orderbook until you log in again. Explore - - - Loading market data - Laden von Marktdaten - There is no chart data for this ticker yet @@ -1981,6 +1976,11 @@ They will be removed from the orderbook until you log in again. Please wait, %1 is %2 + + + Loading ticker chart data + + % activated... @@ -1992,18 +1992,18 @@ They will be removed from the orderbook until you log in again. Handelsinformationen - + Chart Chart - + Orders Order - + History Historie @@ -2025,7 +2025,7 @@ They will be removed from the orderbook until you log in again. - + Address Book Adressbuch @@ -2050,22 +2050,27 @@ They will be removed from the orderbook until you log in again. Schlagworte - + + No contacts found. + + + + Edit Bearbeiten - + Delete Löschen - + address copied to clipboard Adresse in die Zwischenablage kopiert - + This contact does not have any registered address. Dieser Kontakt hat keine registrierte Adresse. @@ -3570,6 +3575,11 @@ Bitte wählen Sie eine neue Order aus. copied to clipboard In die Zwischenablage kopiert + + + Search for Update + + About & Version @@ -3643,6 +3653,17 @@ Bitte wählen Sie eine neue Order aus. MM2 Version copied to clipboard. MM2 Version in die Zwischenablage kopiert. + + + + RPC Port + + + + + RPC Port copied to clipboard. + + @@ -3655,27 +3676,22 @@ Bitte wählen Sie eine neue Order aus. - + Qt version Qt Version - + Qt Version Qt Version - + Qt Version copied to clipboard. Qt Version in die Zwischenablage kopiert. - - Search Update - Update suchen - - - + Logout Abmelden @@ -4563,7 +4579,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. diff --git a/atomic_defi_design/assets/languages/atomic_defi_en.ts b/atomic_defi_design/assets/languages/atomic_defi_en.ts index 7b6367813e..8a413639f9 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_en.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_en.ts @@ -515,17 +515,17 @@ Chart - - Loading market data + + Loading pair chart data - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1955,11 +1955,6 @@ They will be removed from the orderbook until you log in again. Explore - - - Loading market data - - There is no chart data for this ticker yet @@ -1980,6 +1975,11 @@ They will be removed from the orderbook until you log in again. Please wait, %1 is %2 + + + Loading ticker chart data + + % activated... @@ -1991,18 +1991,18 @@ They will be removed from the orderbook until you log in again. - + Chart - + Orders - + History @@ -2024,7 +2024,7 @@ They will be removed from the orderbook until you log in again. - + Address Book @@ -2049,22 +2049,27 @@ They will be removed from the orderbook until you log in again. - + + No contacts found. + + + + Edit - + Delete - + address copied to clipboard - + This contact does not have any registered address. @@ -3641,6 +3646,17 @@ Please select a new order. MM2 Version copied to clipboard. + + + + RPC Port + + + + + RPC Port copied to clipboard. + + @@ -3653,27 +3669,27 @@ Please select a new order. - + Qt version - + Qt Version - + Qt Version copied to clipboard. - - Search Update + + Search for Update - + Logout @@ -4553,7 +4569,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. diff --git a/atomic_defi_design/assets/languages/atomic_defi_es.ts b/atomic_defi_design/assets/languages/atomic_defi_es.ts index ece7e6033c..e17cc56aba 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_es.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_es.ts @@ -515,17 +515,17 @@ Chart - - Loading market data - Cargando datos de mercado + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1958,11 +1958,6 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión.Explore - - - Loading market data - Cargando datos de mercado - There is no chart data for this ticker yet @@ -1983,6 +1978,11 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión.Please wait, %1 is %2 Por favor espera %1 es %2 + + + Loading ticker chart data + + % activated... @@ -1994,18 +1994,18 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión.Información de Intercambios - + Chart Gráfico - + Orders Pedidos - + History Historial @@ -2027,7 +2027,7 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión. - + Address Book Libreta de direcciones @@ -2052,22 +2052,27 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión.Etiquetas - + + No contacts found. + + + + Edit Editar - + Delete Eliminar - + address copied to clipboard dirección copiada al portapapeles - + This contact does not have any registered address. Este contacto no tiene ninguna dirección registrada. @@ -3645,6 +3650,17 @@ Seleccione un nuevo pedido. MM2 Version copied to clipboard. Versión MM2 copiada al portapapeles. + + + + RPC Port + + + + + RPC Port copied to clipboard. + + @@ -3657,27 +3673,27 @@ Seleccione un nuevo pedido. - + Qt version Versión Qt - + Qt Version Versión Qt - + Qt Version copied to clipboard. Versión de Qt copiada al portapapeles. - - Search Update - Buscar Actualizacion + + Search for Update + - + Logout Cerrar sesión @@ -4566,7 +4582,7 @@ Esto puede tardar unos minutos... atomic_dex::settings_page - + An error has occurred. Se ha producido un error. diff --git a/atomic_defi_design/assets/languages/atomic_defi_fr.ts b/atomic_defi_design/assets/languages/atomic_defi_fr.ts index 2fd93a2b52..cfc2eac0d7 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_fr.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_fr.ts @@ -515,17 +515,17 @@ Chart - - Loading market data - Chargement des données de marché + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1955,11 +1955,6 @@ They will be removed from the orderbook until you log in again. Explore - - - Loading market data - Chargement des données de marché - There is no chart data for this ticker yet @@ -1980,6 +1975,11 @@ They will be removed from the orderbook until you log in again. Please wait, %1 is %2 + + + Loading ticker chart data + + % activated... @@ -1991,18 +1991,18 @@ They will be removed from the orderbook until you log in again. Informations de Trading - + Chart Chart - + Orders Ordres - + History Historique @@ -2024,7 +2024,7 @@ They will be removed from the orderbook until you log in again. - + Address Book Carnet d'adresses @@ -2049,22 +2049,27 @@ They will be removed from the orderbook until you log in again. Tags - + + No contacts found. + + + + Edit Éditer - + Delete Supprimez - + address copied to clipboard - + This contact does not have any registered address. @@ -3570,6 +3575,11 @@ Please select a new order. copied to clipboard copié dans le presse-papier + + + Search for Update + + Reset @@ -3615,6 +3625,17 @@ Please select a new order. MM2 Version copied to clipboard. MM2 Version copiée dans le presse-papiers. + + + + RPC Port + + + + + RPC Port copied to clipboard. + + @@ -3627,27 +3648,22 @@ Please select a new order. - + Qt version Version de Qt - + Qt Version Qt Version - + Qt Version copied to clipboard. Version Qt copiée dans le presse-papiers. - - Search Update - Rechercher une mise à jour - - - + Logout Se déconnecter @@ -4553,7 +4569,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. diff --git a/atomic_defi_design/assets/languages/atomic_defi_ru.ts b/atomic_defi_design/assets/languages/atomic_defi_ru.ts index a8d02cf8e8..b4c0cb59a6 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_ru.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_ru.ts @@ -515,17 +515,17 @@ Chart - - Loading market data - Загрузка рыночных данных + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1961,11 +1961,6 @@ They will be removed from the orderbook until you log in again. Explore - - - Loading market data - Загрузка рыночных данных - There is no chart data for this ticker yet @@ -1986,6 +1981,11 @@ They will be removed from the orderbook until you log in again. Please wait, %1 is %2 + + + Loading ticker chart data + + % activated... @@ -1997,18 +1997,18 @@ They will be removed from the orderbook until you log in again. Торговая информация - + Chart График - + Orders Ордеры - + History История @@ -2030,7 +2030,7 @@ They will be removed from the orderbook until you log in again. - + Address Book Адресная книга @@ -2055,22 +2055,27 @@ They will be removed from the orderbook until you log in again. Теги - + + No contacts found. + + + + Edit Редактировать - + Delete Удалить - + address copied to clipboard - + This contact does not have any registered address. @@ -3576,6 +3581,11 @@ Please select a new order. copied to clipboard скопировано в буфер + + + Search for Update + + Reset @@ -3621,6 +3631,17 @@ Please select a new order. MM2 Version copied to clipboard. Версия MM2 скопирована в буфер обмена. + + + + RPC Port + + + + + RPC Port copied to clipboard. + + @@ -3633,27 +3654,22 @@ Please select a new order. - + Qt version Версия Qt - + Qt Version Версия Qt - + Qt Version copied to clipboard. Версия Qt скопирована в буфер обмена. - - Search Update - Проверить на обновления - - - + Logout Выход @@ -4559,7 +4575,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. diff --git a/atomic_defi_design/assets/languages/atomic_defi_tr.ts b/atomic_defi_design/assets/languages/atomic_defi_tr.ts index 49f3e80d63..00238a3206 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_tr.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_tr.ts @@ -515,17 +515,17 @@ Chart - - Loading market data - Piyasa bilgisi yükleniyor + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1949,11 +1949,6 @@ They will be removed from the orderbook until you log in again. Explore - - - Loading market data - Piyasa bilgisi yükleniyor - There is no chart data for this ticker yet @@ -1974,6 +1969,11 @@ They will be removed from the orderbook until you log in again. Please wait, %1 is %2 + + + Loading ticker chart data + + % activated... @@ -1985,18 +1985,18 @@ They will be removed from the orderbook until you log in again. Al Sat Bilgisi - + Chart Grafik - + Orders Emirler - + History Tarihçe @@ -2018,7 +2018,7 @@ They will be removed from the orderbook until you log in again. - + Address Book Adres Defteri @@ -2043,22 +2043,27 @@ They will be removed from the orderbook until you log in again. Etiketler - + + No contacts found. + + + + Edit Düzenle - + Delete Sil - + address copied to clipboard - + This contact does not have any registered address. @@ -3564,6 +3569,11 @@ Please select a new order. copied to clipboard + + + Search for Update + + Reset @@ -3609,6 +3619,17 @@ Please select a new order. MM2 Version copied to clipboard. + + + + RPC Port + + + + + RPC Port copied to clipboard. + + @@ -3621,27 +3642,22 @@ Please select a new order. - + Qt version Qt sürümü - + Qt Version - + Qt Version copied to clipboard. - - Search Update - Güncelleme Ara - - - + Logout Çıkış @@ -4547,7 +4563,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. diff --git a/src/app/app.cpp b/src/app/app.cpp index 54cfc55fb4..a3a8fdf0cd 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -43,7 +43,6 @@ #include "atomicdex/services/mm2/auto.update.maker.order.service.hpp" #include "atomicdex/services/price/komodo_prices/komodo.prices.provider.hpp" #include "atomicdex/services/price/coingecko/coingecko.wallet.charts.hpp" -#include "atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp" #include "atomicdex/services/price/orderbook.scanner.service.hpp" namespace @@ -346,9 +345,6 @@ namespace atomic_dex if (m_event_actions[events_action::need_a_full_refresh_of_mm2]) { system_manager_.create_system(system_manager_); - - // system_manager_.create_system(system_manager_); - // system_manager_.create_system(system_manager_); connect_signals(); m_event_actions[events_action::need_a_full_refresh_of_mm2] = false; } @@ -500,8 +496,6 @@ namespace atomic_dex system_manager_.create_system(system_manager_, settings_page_system.get_cfg()); system_manager_.create_system(system_manager_); system_manager_.create_system(system_manager_); - //system_manager_.create_system(system_manager_); - //system_manager_.create_system(system_manager_); system_manager_.create_system(); system_manager_.create_system(); system_manager_.create_system(system_manager_); diff --git a/src/core/atomicdex/api/coinpaprika/coinpaprika.cpp b/src/core/atomicdex/api/coinpaprika/coinpaprika.cpp deleted file mode 100644 index 0287e13302..0000000000 --- a/src/core/atomicdex/api/coinpaprika/coinpaprika.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/****************************************************************************** - * Copyright © 2013-2024 The Komodo Platform Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * Komodo Platform software, including this file may be copied, modified, * - * propagated or distributed except according to the terms contained in the * - * LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -//! Deps -#include -#include - -//! Project Headers -#include "atomicdex/api/coinpaprika/coinpaprika.hpp" -#include "atomicdex/utilities/global.utilities.hpp" - -//! Private -#include "atomicdex/utilities/nlohmann.json.sax.private.cpp" - -namespace -{ - //! Constants - constexpr const char* g_coinpaprika_endpoint = "https://api.coinpaprika.com/v1/"; - web::http::client::http_client_config g_paprika_cfg{[]() { - web::http::client::http_client_config cfg; - cfg.set_validate_certificates(false); - cfg.set_timeout(std::chrono::seconds(5)); - return cfg; - }()}; - t_http_client_ptr g_coinpaprika_client = std::make_unique(FROM_STD_STR(g_coinpaprika_endpoint), g_paprika_cfg); -} // namespace - -namespace atomic_dex -{ - namespace coinpaprika::api - { - void - to_json(nlohmann::json& j, const price_converter_request& evt) - { - j["base_currency_id"] = evt.base_currency_id; - j["quote_currency_id"] = evt.quote_currency_id; - j["amount"] = 1; - } - - void - from_json(const nlohmann::json& j, price_converter_answer& evt) - { - // utils::details::my_json_sax sx; - // nlohmann::json::sax_parse(j.dump(), &sx); - - evt.base_currency_id = j.at("base_currency_id").get(); - evt.base_currency_name = j.at("base_currency_name").get(); - evt.base_price_last_updated = j.at("base_price_last_updated").get(); - evt.quote_currency_id = j.at("quote_currency_id").get(); - evt.quote_currency_name = j.at("quote_currency_name").get(); - evt.quote_price_last_updated = j.at("quote_price_last_updated").get(); - evt.amount = j.at("amount").get(); - evt.price = std::to_string(j.at("price").get()); - - std::replace(evt.price.begin(), evt.price.end(), ',', '.'); - } - - void - from_json(const nlohmann::json& j, ticker_info_answer& evt) - { - evt.answer = j.at("quotes"); - } - - void - from_json(const nlohmann::json& j, ticker_historical_answer& evt) - { - evt.answer = j; - } - - pplx::task - async_price_converter(const price_converter_request& request) - { - using namespace std::string_literals; - web::http::http_request req; - req.set_method(web::http::methods::GET); - auto&& [base_id, quote_id] = request; - const auto url = "/price-converter?base_currency_id="s + base_id + ""e_currency_id="s + quote_id + "&amount=1"s; - req.set_request_uri(FROM_STD_STR(url)); - return g_coinpaprika_client->request(req); - } - - pplx::task - async_ticker_info(const ticker_infos_request& request) - { - using ranges::views::ints; - using ranges::views::zip; - using namespace std::string_literals; - web::http::http_request req; - req.set_method(web::http::methods::GET); - auto&& [ticker_id, quotes] = request; - auto url = "/tickers/"s + ticker_id + "?quotes="s; - for (auto&& [cur_quote, idx]: zip(quotes, ints(0u, ranges::unreachable))) - { - url.append(cur_quote); - - //! Append only if not last element, idx start at 0, if idx + 1 == quotes.size(), we are on the last elemnt, we don't append. - if (idx < quotes.size() - 1) - { - url.append(","); - } - } - SPDLOG_INFO("url: {}", TO_STD_STR(g_coinpaprika_client->base_uri().to_string()) + url); - req.set_request_uri(FROM_STD_STR(url)); - return g_coinpaprika_client->request(req); - } - - pplx::task - async_ticker_historical(const ticker_historical_request& request) - { - using namespace std::string_literals; - web::http::http_request req; - req.set_method(web::http::methods::GET); - auto&& [ticker_id, timestamp, interval] = request; - const auto url = "/tickers/"s + ticker_id + "/historical?start="s + std::to_string(timestamp) + "&interval="s + interval; - SPDLOG_INFO("url: {}", url); - req.set_request_uri(FROM_STD_STR(url)); - return g_coinpaprika_client->request(req); - } - } // namespace coinpaprika::api -} // namespace atomic_dex diff --git a/src/core/atomicdex/api/coinpaprika/coinpaprika.hpp b/src/core/atomicdex/api/coinpaprika/coinpaprika.hpp deleted file mode 100644 index 3650d3f733..0000000000 --- a/src/core/atomicdex/api/coinpaprika/coinpaprika.hpp +++ /dev/null @@ -1,139 +0,0 @@ -/****************************************************************************** - * Copyright © 2013-2024 The Komodo Platform Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * Komodo Platform software, including this file may be copied, modified, * - * propagated or distributed except according to the terms contained in the * - * LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#pragma once - -//! Deps -#include -#include -#include - -//! Project Headers -#include "atomicdex/utilities/cpprestsdk.utilities.hpp" - -namespace -{ - constexpr const std::size_t g_nb_hours_in_a_week{168}; -} - -namespace atomic_dex -{ - namespace coinpaprika::api - { - struct ticker_historical_request - { - std::string ticker_currency_id; - std::size_t timestamp{static_cast( - std::chrono::duration_cast((std::chrono::system_clock::now() - std::chrono::hours(g_nb_hours_in_a_week)).time_since_epoch()).count())}; - std::string interval{"1d"}; - }; - - struct ticker_historical_answer - { - nlohmann::json answer{nlohmann::json::array()}; - int rpc_result_code; - std::string raw_result; - }; - - struct ticker_infos_request - { - std::string ticker_currency_id; - std::vector ticker_quotes; - }; - - struct ticker_info_answer - { - nlohmann::json answer; - int rpc_result_code; - std::string raw_result; - }; - - struct price_converter_request - { - std::string base_currency_id; - std::string quote_currency_id; - }; - - struct price_converter_answer - { - std::string base_currency_id; - std::string base_currency_name; - std::string base_price_last_updated; - std::string quote_currency_id; - std::string quote_currency_name; - std::string quote_price_last_updated; - std::size_t amount; - std::string price{"0.00"}; ///< we need trick here - int rpc_result_code; - std::string raw_result; - }; - - void to_json(nlohmann::json& j, const price_converter_request& evt); - - void from_json(const nlohmann::json& j, price_converter_answer& evt); - - void from_json(const nlohmann::json& j, ticker_info_answer& evt); - - void from_json(const nlohmann::json& j, ticker_historical_answer& evt); - - pplx::task async_price_converter(const price_converter_request& request); - pplx::task async_ticker_info(const ticker_infos_request& request); - pplx::task async_ticker_historical(const ticker_historical_request& request); - - template - TAnswer static inline process_generic_resp(web::http::http_response resp) - { - TAnswer answer; - std::string body = TO_STD_STR(resp.extract_string(true).get()); - if (resp.status_code() == static_cast(antara::app::http_code::bad_request)) - { - SPDLOG_WARN("rpc answer code is 400 (Bad Parameters), body: {}", body); - answer.rpc_result_code = resp.status_code(); - answer.raw_result = body; - return answer; - } - if (resp.status_code() == static_cast(antara::app::http_code::too_many_requests)) - { - SPDLOG_WARN("rpc answer code is 429 (Too Many requests), body: {}", body); - answer.rpc_result_code = resp.status_code(); - answer.raw_result = body; - return answer; - } - try - { - const auto json_answer = nlohmann::json::parse(body); - from_json(json_answer, answer); - answer.rpc_result_code = resp.status_code(); - answer.raw_result = body; - } - catch (const std::exception& error) - { - SPDLOG_ERROR("exception caught: error[{}], body: {}", error.what(), body); - answer.rpc_result_code = -1; - answer.raw_result = error.what(); - } - return answer; - } - } // namespace coinpaprika::api - - - using t_price_converter_answer = coinpaprika::api::price_converter_answer; - using t_price_converter_request = coinpaprika::api::price_converter_request; - using t_ticker_info_answer = coinpaprika::api::ticker_info_answer; - using t_ticker_infos_request = coinpaprika::api::ticker_infos_request; - using t_ticker_historical_answer = coinpaprika::api::ticker_historical_answer; - using t_ticker_historical_request = coinpaprika::api::ticker_historical_request; -} // namespace atomic_dex diff --git a/src/core/atomicdex/config/app.cfg.cpp b/src/core/atomicdex/config/app.cfg.cpp index 78ec9fda01..770b7be2e4 100644 --- a/src/core/atomicdex/config/app.cfg.cpp +++ b/src/core/atomicdex/config/app.cfg.cpp @@ -165,7 +165,7 @@ namespace atomic_dex //! If it's fiat, i set the first element of the possible currencies to the new currency (the new fiat here) and i also set the current fiat if (is_this_currency_a_fiat(config, new_currency)) { - SPDLOG_INFO("{} is fiat, setting it as current fiat and possible currencies", new_currency); + // SPDLOG_INFO("{} is fiat, setting it as current fiat and possible currencies", new_currency); config.current_fiat = new_currency; config.current_fiat_sign = config.current_currency_sign; config.possible_currencies[0] = new_currency; @@ -173,11 +173,11 @@ namespace atomic_dex if (std::count(config.recommended_fiat.begin(), config.recommended_fiat.end(), new_currency)) { - SPDLOG_INFO("{} is already in recommended fiats", new_currency); + // SPDLOG_INFO("{} is already in recommended fiats", new_currency); update_recommended_fiat = false; } if (update_recommended_fiat) { - SPDLOG_INFO("Adding {} to recommended fiats", new_currency); + // SPDLOG_INFO("Adding {} to recommended fiats", new_currency); config.recommended_fiat.pop_back(); config.recommended_fiat.insert(config.recommended_fiat.begin(), new_currency); } diff --git a/src/core/atomicdex/services/internet/internet.checker.service.cpp b/src/core/atomicdex/services/internet/internet.checker.service.cpp index 9afafd488f..e194dbe2ce 100644 --- a/src/core/atomicdex/services/internet/internet.checker.service.cpp +++ b/src/core/atomicdex/services/internet/internet.checker.service.cpp @@ -32,7 +32,6 @@ namespace return cfg; }()}; - t_http_client_ptr g_paprika_proxy_http_client{std::make_unique(FROM_STD_STR("https://api.coinpaprika.com"), g_cfg)}; std::atomic_bool g_mm2_default_coins_ready{false}; pplx::task @@ -164,7 +163,7 @@ namespace atomic_dex void internet_service_checker::fetch_internet_connection() { - //query_internet(g_paprika_proxy_http_client, "/v1/coins/btc-bitcoin", &internet_service_checker::is_paprika_provider_alive); + // TODO: This is only checking mm2 connection, not connection to the internet. if (this->m_system_manager.has_system() && g_mm2_default_coins_ready) { auto& mm2 = this->m_system_manager.get_system(); diff --git a/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.cpp b/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.cpp deleted file mode 100644 index 9719887871..0000000000 --- a/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/****************************************************************************** - * Copyright © 2013-2024 The Komodo Platform Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * Komodo Platform software, including this file may be copied, modified, * - * propagated or distributed except according to the terms contained in the * - * LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -// Deps Headers -#include - -// Project Headers -#include "atomicdex/pages/qt.portfolio.page.hpp" -#include "atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp" - -namespace -{ - //! Using namespace - using namespace std::chrono_literals; - using namespace atomic_dex::coinpaprika::api; - - //! Constants - constexpr std::uint16_t g_pending_init_tasks_limit = 3; -} // namespace - -//! Constructor/Destructor -namespace atomic_dex -{ - coinpaprika_provider::coinpaprika_provider(entt::registry& registry, ag::ecs::system_manager& system_manager) : - system(registry), m_system_manager(system_manager) - { - SPDLOG_INFO("coinpaprika_provider created"); - disable(); - dispatcher_.sink().connect<&coinpaprika_provider::on_mm2_started>(*this); - dispatcher_.sink().connect<&coinpaprika_provider::on_coin_enabled>(*this); - dispatcher_.sink().connect<&coinpaprika_provider::on_coin_disabled>(*this); - } - - coinpaprika_provider::~coinpaprika_provider() - { - SPDLOG_INFO("coinpaprika_provider destroyed"); - dispatcher_.sink().disconnect<&coinpaprika_provider::on_mm2_started>(*this); - dispatcher_.sink().disconnect<&coinpaprika_provider::on_coin_enabled>(*this); - dispatcher_.sink().disconnect<&coinpaprika_provider::on_coin_disabled>(*this); - } -} // namespace atomic_dex - -//! Private Generics -namespace atomic_dex -{ - template - TAnswer - coinpaprika_provider::get_infos(const std::string& ticker, const TRegistry& registry, TLockable& mutex) const - { - std::shared_lock lock(mutex); - const auto it = registry.find(ticker); - return it != registry.cend() ? it->second : TAnswer{}; - } -} // namespace atomic_dex - -//! RPC Generics -namespace atomic_dex -{ - void - coinpaprika_provider::verify_idx(t_ref_count_idx idx, uint16_t target_size, const std::vector& tickers) - { - if (idx != nullptr) - { - const auto cur = idx->fetch_add(1) + 1; - // SPDLOG_DEBUG("cur: {}, target size: {}, remaining before adding in the model: {}", cur, target_size, target_size - cur); - if (cur == target_size) - { - if (not tickers.empty()) - { - dispatcher_.trigger(tickers); - } - else - { - this->dispatcher_.trigger(""); - } - } - } - } - - template - void - coinpaprika_provider::generic_post_verification(std::shared_mutex& mtx, TContainer& container, std::string&& ticker, TAnswer&& answer, Args... args) - { - { - std::unique_lock lock(mtx); - container.insert_or_assign(std::move(ticker), std::forward(answer)); - } - verify_idx(std::move(args)...); - } - - template - void - coinpaprika_provider::generic_rpc_paprika_process( - const TRequest& request, std::string ticker, std::shared_mutex& mtx, std::unordered_map& container, TExecutorFunctor&& functor, - Args... args) - { - const auto answer_functor = [this, &mtx, &container, functor = std::forward(functor), request, ticker = std::move(ticker), - ... args = std::move(args)](web::http::http_response resp) mutable { - const auto answer = process_generic_resp(resp); - if (answer.rpc_result_code == static_cast(antara::app::http_code::too_many_requests)) - { - std::this_thread::sleep_for(1s); - generic_rpc_paprika_process(request, std::move(ticker), mtx, container, std::forward(functor), std::move(args)...); - } - else - { - generic_post_verification(mtx, container, std::move(ticker), std::move(answer), std::move(args)...); - } - }; - - functor(request).then(answer_functor).then(&handle_exception_pplx_task); - } -} // namespace atomic_dex - -//! RPC call -namespace atomic_dex -{ - template - void - coinpaprika_provider::process_provider(const coin_config_t& current_coin, Args... args) - { - const price_converter_request request{.base_currency_id = current_coin.coinpaprika_id, .quote_currency_id = "usd-us-dollars"}; - generic_rpc_paprika_process( - request, current_coin.ticker, m_provider_mutex, m_usd_rate_providers, - [](auto&& request) { return async_price_converter(std::forward(request)); }, std::move(args)...); - } - - template - void - coinpaprika_provider::process_ticker_infos(const coin_config_t& current_coin, Args... args) - { - const ticker_infos_request request{.ticker_currency_id = current_coin.coinpaprika_id, .ticker_quotes = {"USD", "EUR", "BTC"}}; - generic_rpc_paprika_process( - request, current_coin.ticker, m_ticker_infos_mutex, m_ticker_infos_registry, - [](auto&& request) { return async_ticker_info(std::forward(request)); }, std::move(args)...); - } - - template - void - coinpaprika_provider::process_ticker_historical(const coin_config_t& current_coin, Args... args) - { - const ticker_historical_request request{.ticker_currency_id = current_coin.coinpaprika_id, .interval = "2h"}; - generic_rpc_paprika_process( - request, current_coin.ticker, m_ticker_historical_mutex, m_ticker_historical_registry, - [](auto&& request) { return async_ticker_historical(std::forward(request)); }, std::move(args)...); - } -} // namespace atomic_dex - -//! System Override -namespace atomic_dex -{ - void - coinpaprika_provider::update() - { - } -} // namespace atomic_dex - -//! Events -namespace atomic_dex -{ - void - coinpaprika_provider::on_mm2_started([[maybe_unused]] const mm2_started& evt) - { - update_ticker_and_provider(); - } - - void - coinpaprika_provider::on_coin_enabled(const coin_enabled& evt) - { - SPDLOG_INFO("{} enabled, retrieve coinpaprika infos", fmt::format("{}", fmt::join(evt.tickers, ", "))); - auto idx{std::make_shared(0)}; - const auto target_size = evt.tickers.size() * g_pending_init_tasks_limit; - const auto* global_cfg_system = m_system_manager.get_system().get_global_cfg(); - for (auto&& ticker: evt.tickers) - { - const auto config = global_cfg_system->get_coin_info(ticker); - if (config.coinpaprika_id != "test-coin") - { - process_provider(config, idx, target_size, evt.tickers); - process_ticker_infos(config, idx, target_size, evt.tickers); - process_ticker_historical(config, idx, target_size, evt.tickers); - } - else - { - const std::uint16_t cur = idx->fetch_add(g_pending_init_tasks_limit) + g_pending_init_tasks_limit; ///< Manually skip the above 3 operations - if (cur == target_size) - { - this->dispatcher_.trigger(evt.tickers); - } - } - } - } - - void - coinpaprika_provider::on_coin_disabled(const coin_disabled& evt) - { - SPDLOG_INFO("{} disabled, removing from paprika provider", evt.ticker); - std::unique_lock lock(m_provider_mutex); - m_usd_rate_providers.erase(evt.ticker); - } -} // namespace atomic_dex - -//! Public member functions -namespace atomic_dex -{ - void - coinpaprika_provider::update_ticker_and_provider() - { - const auto coins = this->m_system_manager.get_system().get_global_cfg()->get_enabled_coins(); - auto idx{std::make_shared(0)}; - const auto target_size = coins.size(); - for (auto&& [_, current_coin]: coins) - { - if (current_coin.coinpaprika_id == "test-coin") - { - const std::uint16_t cur = idx->fetch_add(1) + 1; - if (cur == target_size) - { - dispatcher_.trigger(""); - } - continue; - } - process_ticker_infos(current_coin); - process_ticker_historical(current_coin); - process_provider(current_coin, idx, target_size, std::vector{}); - } - } - - std::string - coinpaprika_provider::get_rate_conversion(const std::string& ticker) const - { - return get_infos(ticker, m_usd_rate_providers, m_provider_mutex).price; - } - - t_ticker_info_answer - coinpaprika_provider::get_ticker_infos(const std::string& ticker) const - { - return get_infos(ticker, m_ticker_infos_registry, m_ticker_infos_mutex); - } - - t_ticker_historical_answer - coinpaprika_provider::get_ticker_historical(const std::string& ticker) const - { - return get_infos(ticker, m_ticker_historical_registry, m_ticker_historical_mutex); - } -} // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp b/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp deleted file mode 100644 index 01352719e5..0000000000 --- a/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/****************************************************************************** - * Copyright © 2013-2024 The Komodo Platform Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * Komodo Platform software, including this file may be copied, modified, * - * propagated or distributed except according to the terms contained in the * - * LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#pragma once - -//! STD -#include - -//! Deps -#include - -//! Project Headers -#include "atomicdex/api/coinpaprika/coinpaprika.hpp" -#include "atomicdex/events/events.hpp" - -namespace atomic_dex -{ - namespace ag = antara::gaming; - - class coinpaprika_provider final : public ag::ecs::pre_update_system - { - //! Typedefs - using t_ref_count_idx = std::shared_ptr; - using t_providers_registry = std::unordered_map; - using t_ticker_infos_registry = std::unordered_map; - using t_ticker_historical_registry = std::unordered_map; - - //! Private fields - - //! ag::system_manager - ag::ecs::system_manager& m_system_manager; - - //! Containers - t_providers_registry m_usd_rate_providers{}; ///< USD Rate Providers - t_ticker_infos_registry m_ticker_infos_registry{}; ///< Ticker info registry, key is the ticker - t_ticker_historical_registry m_ticker_historical_registry{}; ///< Ticker historical registry, key is the ticker - - //! Mutexes - mutable std::shared_mutex m_ticker_historical_mutex; - mutable std::shared_mutex m_ticker_infos_mutex; - mutable std::shared_mutex m_provider_mutex; - - //! Private member functions - void verify_idx(t_ref_count_idx idx = nullptr, uint16_t target_size = 0, const std::vector& tickers = {}); - - //! Private templated member functions - template - TAnswer get_infos(const std::string& ticker, const TRegistry& registry, TLockable& mutex) const ; - - template - void generic_post_verification(std::shared_mutex& mtx, TContainer& container, std::string&& ticker, TAnswer&& answer, Args... args); - - template - void generic_rpc_paprika_process( - const TRequest& request, std::string ticker, std::shared_mutex& mtx, std::unordered_map& container, - TExecutorFunctor&& functor, Args... args); - - //! Private RPC Call - template - void process_provider(const coin_config_t& current_coin, Args... args); - template - void process_ticker_infos(const coin_config_t& current_coin, Args... args); - template - void process_ticker_historical(const coin_config_t& current_coin, Args... args); - - public: - //! Deleted operation - coinpaprika_provider(coinpaprika_provider& other) = delete; - coinpaprika_provider(coinpaprika_provider&& other) = delete; - coinpaprika_provider& operator=(coinpaprika_provider& other) = delete; - coinpaprika_provider& operator=(coinpaprika_provider&& other) = delete; - - //! Constructor - coinpaprika_provider(entt::registry& registry, ag::ecs::system_manager& system_manager) ; - - //! Destructor - ~coinpaprika_provider() final; - - ///< Public API - - //! Update all the data of the provider in an async way - void update_ticker_and_provider(); - - //! Get the rate conversion for the given fiat. - [[nodiscard]] std::string get_rate_conversion(const std::string& ticker) const ; - - //! Get the ticker informations. - [[nodiscard]] t_ticker_info_answer get_ticker_infos(const std::string& ticker) const ; - - //! Get the ticker informations. - [[nodiscard]] t_ticker_historical_answer get_ticker_historical(const std::string& ticker) const ; - - ///< Events - - //! Event that occur when the mm2 process is launched correctly. - void on_mm2_started(const mm2_started& evt) ; - - //! Event that occur when a coin is correctly enabled. - void on_coin_enabled(const coin_enabled& evt) ; - - //! Event that occur when a coin is correctly disabled. - void on_coin_disabled(const coin_disabled& evt) ; - - //! Override ag::system functions - void update() final; - }; -} // namespace atomic_dex - -REFL_AUTO(type(atomic_dex::coinpaprika_provider)) \ No newline at end of file diff --git a/src/core/atomicdex/services/price/defi.stats.cpp b/src/core/atomicdex/services/price/defi.stats.cpp index 22bbd98d4c..23a0e2f784 100644 --- a/src/core/atomicdex/services/price/defi.stats.cpp +++ b/src/core/atomicdex/services/price/defi.stats.cpp @@ -17,7 +17,6 @@ //! Project Headers #include "atomicdex/services/price/defi.stats.hpp" #include "atomicdex/services/price/komodo_prices/komodo.prices.provider.hpp" -#include "atomicdex/api/coinpaprika/coinpaprika.hpp" #include "atomicdex/pages/qt.settings.page.hpp" #include "atomicdex/services/price/global.provider.hpp" @@ -143,7 +142,7 @@ namespace atomic_dex } auto defi_ticker_stats = m_defi_ticker_stats.get(); - // SPDLOG_INFO("Volume data: {}", defi_ticker_stats.dump(4)); + SPDLOG_INFO("Volume data: {}", defi_ticker_stats.dump(4)); if (defi_ticker_stats.contains("data")) { diff --git a/src/core/atomicdex/services/price/global.provider.cpp b/src/core/atomicdex/services/price/global.provider.cpp index 1da473e6a7..6f3777b012 100644 --- a/src/core/atomicdex/services/price/global.provider.cpp +++ b/src/core/atomicdex/services/price/global.provider.cpp @@ -16,7 +16,6 @@ //! Project Headers #include "atomicdex/services/price/global.provider.hpp" -#include "atomicdex/api/coinpaprika/coinpaprika.hpp" #include "atomicdex/pages/qt.settings.page.hpp" #include "atomicdex/services/price/komodo_prices/komodo.prices.provider.hpp" @@ -100,63 +99,15 @@ 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; + // 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) { SPDLOG_WARN("refresh other coins rates max try reached, skipping"); return; } - using namespace std::chrono_literals; - coinpaprika::api::price_converter_request request{.base_currency_id = "usd-us-dollars", .quote_currency_id = quote_id}; - auto error_functor = [this, quote_id, ticker, with_update_providers, nb_try_load = nb_try.load()](pplx::task previous_task) - { - try - { - previous_task.wait(); - } - catch (const std::exception& e) - { - SPDLOG_ERROR("pplx task error from refresh_other_coins_rates: {} - nb_try {}", e.what(), nb_try_load); - using namespace std::chrono_literals; - std::this_thread::sleep_for(1s); - this->refresh_other_coins_rates(quote_id, ticker, with_update_providers, nb_try_load); - }; - }; - coinpaprika::api::async_price_converter(request) - .then( - [this, quote_id, ticker, with_update_providers, nb_try_cap = nb_try.load()](web::http::http_response resp) - { - auto answer = coinpaprika::api::process_generic_resp(resp); - if (answer.rpc_result_code == static_cast(antara::app::http_code::too_many_requests)) - { - std::this_thread::sleep_for(1s); - SPDLOG_WARN("too many request - retrying"); - this->refresh_other_coins_rates(quote_id, ticker, with_update_providers, nb_try_cap); - } - else - { - SPDLOG_INFO("Successfully get the coinpaprika::api::async_price_converter answer after {} try", nb_try_cap); - if (answer.raw_result.find("error") == std::string::npos) - { - if (not answer.price.empty()) - { - std::unique_lock lock(m_coin_rate_mutex); - this->m_coin_rate_providers[ticker] = answer.price; - } - } - else - { - std::unique_lock lock(m_coin_rate_mutex); - this->m_coin_rate_providers[ticker] = "0.00"; - } - } - if (with_update_providers) - { - //this->m_system_manager.get_system().update_ticker_and_provider(); - } - }) - .then(error_functor); } global_price_service::global_price_service(entt::registry& registry, ag::ecs::system_manager& system_manager, atomic_dex::cfg& cfg) : diff --git a/src/core/atomicdex/services/price/orderbook.scanner.service.cpp b/src/core/atomicdex/services/price/orderbook.scanner.service.cpp index 823ec28708..ed6b2dcfcd 100644 --- a/src/core/atomicdex/services/price/orderbook.scanner.service.cpp +++ b/src/core/atomicdex/services/price/orderbook.scanner.service.cpp @@ -63,9 +63,9 @@ namespace atomic_dex nlohmann::json batch = nlohmann::json::array(); if (rpc.error) { - SPDLOG_ERROR("error: bad answer json for process_best_orders: {}", rpc.error->error); + // SPDLOG_DEBUG("error: bad answer json for process_best_orders: {}", rpc.error->error); this->m_bestorders_busy = false; - SPDLOG_ERROR("Triggering [process_orderbook_finished]: true"); + // SPDLOG_DEBUG("Triggering [process_orderbook_finished]: true"); this->dispatcher_.trigger(true); } else @@ -75,7 +75,7 @@ namespace atomic_dex this->m_best_orders_infos = rpc.result.value(); } this->m_bestorders_busy = false; - SPDLOG_ERROR("Triggering [process_orderbook_finished]: false"); + // SPDLOG_DEBUG("Triggering [process_orderbook_finished]: false"); this->dispatcher_.trigger(false); emit trading_pg.get_orderbook_wrapper()->bestOrdersBusyChanged(); } diff --git a/src/core/atomicdex/utilities/safe.float.cpp b/src/core/atomicdex/utilities/safe.float.cpp index 62dea4f09a..950c79d92c 100644 --- a/src/core/atomicdex/utilities/safe.float.cpp +++ b/src/core/atomicdex/utilities/safe.float.cpp @@ -24,7 +24,7 @@ safe_float(const std::string& from) } catch (const std::exception& error) { - SPDLOG_ERROR("exception caught when creating a floating point number: {}", error.what()); + SPDLOG_ERROR("exception caught when creating a floating point number from {}: {}", from, error.what()); //#if defined(linux) || defined(__APPLE__) // SPDLOG_ERROR("stacktrace: {}", boost::stacktrace::to_string(boost::stacktrace::stacktrace())); //#endif From 0d2974faacb6f16b7c78fc85f83c95ba0ee91f89 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 28 Mar 2024 19:37:47 +0800 Subject: [PATCH 02/26] add pair trades 24hr stat --- .../Dex/Exchange/Trade/OrderBook/Vertical.qml | 3 +- src/core/atomicdex/pages/qt.trading.page.cpp | 10 ++ src/core/atomicdex/pages/qt.trading.page.hpp | 4 + .../atomicdex/services/price/defi.stats.cpp | 135 ++++++++++++++++-- .../atomicdex/services/price/defi.stats.hpp | 9 +- 5 files changed, 142 insertions(+), 19 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml index b73167e100..4a572f8b9d 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml @@ -12,6 +12,7 @@ import Dex.Themes 1.0 as Dex Widget { title: qsTr("Order Book") + readonly property string pair_trades_24hr: API.app.trading_pg.pair_trades_24hr readonly property string pair_volume_24hr: API.app.trading_pg.pair_volume_24hr readonly property string pair: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + "/" + atomic_qt_utilities.retrieve_main_ticker(right_ticker) @@ -61,7 +62,7 @@ Widget Layout.bottomMargin: 2 Layout.alignment: Qt.AlignHCenter color: Dex.CurrentTheme.foregroundColor2 - text_value: pair + qsTr(" traded 24hrs: %1").arg("" + General.convertUsd(pair_volume_24hr) + "") + text_value: pair + qsTr(" 24hrs | %1 | %2 trades").arg(General.convertUsd(pair_volume_24hr)).arg(pair_trades_24hr) font.pixelSize: Style.textSizeSmall1 } } diff --git a/src/core/atomicdex/pages/qt.trading.page.cpp b/src/core/atomicdex/pages/qt.trading.page.cpp index e073806637..7499496a68 100644 --- a/src/core/atomicdex/pages/qt.trading.page.cpp +++ b/src/core/atomicdex/pages/qt.trading.page.cpp @@ -708,6 +708,7 @@ namespace atomic_dex this->m_preferred_order = std::nullopt; this->m_fees = QVariantMap(); this->m_cex_price = "0"; + this->m_pair_trades_24hr = "0"; this->m_pair_volume_24hr = "0"; this->m_post_clear_forms = true; this->set_selected_order_status(SelectedOrderStatus::None); @@ -1394,15 +1395,24 @@ namespace atomic_dex const auto* market_selector = get_market_pairs_mdl(); 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 trades = QString::fromStdString(defi_stats_service.get_trades_24h(base, rel)); QString vol = QString::fromStdString(defi_stats_service.get_volume_24h_usd(base, rel)); if (vol != m_pair_volume_24hr) { + m_pair_trades_24hr = trades; + emit pairTrades24hrChanged(); m_pair_volume_24hr = vol; emit pairVolume24hrChanged(); } } + QString + trading_page::get_pair_trades_24hr() const + { + return m_pair_trades_24hr; + } + QString trading_page::get_pair_volume_24hr() const { diff --git a/src/core/atomicdex/pages/qt.trading.page.hpp b/src/core/atomicdex/pages/qt.trading.page.hpp index af97e46860..ccbbf2c3c3 100644 --- a/src/core/atomicdex/pages/qt.trading.page.hpp +++ b/src/core/atomicdex/pages/qt.trading.page.hpp @@ -59,6 +59,7 @@ namespace atomic_dex Q_PROPERTY(SelectedOrderStatus selected_order_status READ get_selected_order_status WRITE set_selected_order_status NOTIFY selectedOrderStatusChanged) Q_PROPERTY(QString price_reversed READ get_price_reversed NOTIFY priceReversedChanged) Q_PROPERTY(QString pair_volume_24hr READ get_pair_volume_24hr NOTIFY pairVolume24hrChanged) + Q_PROPERTY(QString pair_trades_24hr READ get_pair_trades_24hr NOTIFY pairTrades24hrChanged) Q_PROPERTY(QString cex_price READ get_cex_price NOTIFY cexPriceChanged) Q_PROPERTY(QString cex_price_reversed READ get_cex_price_reversed NOTIFY cexPriceReversedChanged) Q_PROPERTY(QString cex_price_diff READ get_cex_price_diff NOTIFY cexPriceDiffChanged) @@ -115,6 +116,7 @@ namespace atomic_dex QString m_total_amount{"0.00777"}; QString m_cex_price{"0"}; QString m_pair_volume_24hr{"0"}; + QString m_pair_trades_24hr{"0"}; QString m_minimal_trading_amount{"0.0001"}; std::optional m_preferred_order; boost::synchronized_value m_fees; @@ -197,6 +199,7 @@ namespace atomic_dex void set_total_amount(QString total_amount); [[nodiscard]] QString get_base_amount() const; [[nodiscard]] QString get_rel_amount() const; + [[nodiscard]] QString get_pair_trades_24hr() const; [[nodiscard]] QString get_pair_volume_24hr() const; [[nodiscard]] QString get_cex_price() const; [[nodiscard]] QString get_cex_price_reversed() const; @@ -238,6 +241,7 @@ namespace atomic_dex void baseAmountChanged(); void relAmountChanged(); void feesChanged(); + void pairTrades24hrChanged(); void pairVolume24hrChanged(); void cexPriceChanged(); void cexPriceReversedChanged(); diff --git a/src/core/atomicdex/services/price/defi.stats.cpp b/src/core/atomicdex/services/price/defi.stats.cpp index 22bbd98d4c..b747a944b5 100644 --- a/src/core/atomicdex/services/price/defi.stats.cpp +++ b/src/core/atomicdex/services/price/defi.stats.cpp @@ -49,17 +49,17 @@ namespace pplx::cancellation_token_source d_token_source; pplx::task - async_fetch_defi_ticker_stats() + async_fetch_defi_stats_volumes() { web::http::http_request req; req.set_method(web::http::methods::GET); - req.set_request_uri(FROM_STD_STR("api/v3/tickers/summary")); + req.set_request_uri(FROM_STD_STR("api/v3/pairs/volumes_24hr")); SPDLOG_INFO("defi_stats req: {}", TO_STD_STR(req.to_string())); return g_defi_stats_client->request(req, d_token_source.get_token()); } nlohmann::json - process_fetch_defi_ticker_stats_answer(web::http::http_response resp) + process_fetch_defi_stats_volumes_answer(web::http::http_response resp) { std::string body = TO_STD_STR(resp.extract_string(true).get()); if (resp.status_code() == 200) @@ -119,11 +119,11 @@ namespace atomic_dex this->process_update(); }; }; - async_fetch_defi_ticker_stats() + async_fetch_defi_stats_volumes() .then( [this](web::http::http_response resp) { - this->m_defi_ticker_stats = process_fetch_defi_ticker_stats_answer(resp); + this->m_defi_stats_volumes = process_fetch_defi_stats_volumes_answer(resp); nb_try = 0; }) .then(error_functor); @@ -136,33 +136,140 @@ namespace atomic_dex auto ticker = base + "_" + quote; auto ticker_reversed = quote + "_" + base; SPDLOG_INFO("Getting 24hr volume data for {}", ticker); + + // Check if base/quote are the same if (base == quote) { SPDLOG_INFO("Base/quote must be different, no volume data for {}", ticker); return volume_24h_usd; } - auto defi_ticker_stats = m_defi_ticker_stats.get(); - // SPDLOG_INFO("Volume data: {}", defi_ticker_stats.dump(4)); + // Check if defi_stats_volumes is valid + auto defi_stats_volumes = m_defi_stats_volumes.get(); + if (!defi_stats_volumes.is_object()) + { + SPDLOG_WARN("Invalid defi stats volumes data."); + return volume_24h_usd; + } - if (defi_ticker_stats.contains("data")) + // Check if volumes key exists + if (!defi_stats_volumes.contains("volumes")) + { + SPDLOG_WARN("No volumes data available."); + return volume_24h_usd; + } + + // Extract ticker trade_volume_usd safely + if (defi_stats_volumes.at("volumes").contains(ticker)) { - SPDLOG_INFO("Combined volume usd: {}", defi_ticker_stats["combined_volume_usd"]); - if (defi_ticker_stats.at("data").contains(ticker)) + auto volume_node = defi_stats_volumes["volumes"][ticker]["ALL"]["trade_volume_usd"]; + if (volume_node.is_number()) { - volume_24h_usd = defi_ticker_stats.at("data").at(ticker).at("volume_usd_24hr").get(); + volume_24h_usd = std::to_string(volume_node.get()); SPDLOG_INFO("{} volume usd: {}", ticker, volume_24h_usd); } - else if (defi_ticker_stats.at("data").contains(ticker_reversed)) + else if (volume_node.is_null()) + { + SPDLOG_WARN("Volume value is null for {}", ticker); + } + else + { + SPDLOG_WARN("Volume value is not a number for {}: {}", ticker, volume_node.type_name()); + } + } + else if (defi_stats_volumes["volumes"].contains(ticker_reversed)) + { + auto volume_node = defi_stats_volumes["volumes"][ticker_reversed]["ALL"]["trade_volume_usd"]; + if (volume_node.is_number()) { - volume_24h_usd = defi_ticker_stats.at("data").at(ticker_reversed).at("volume_usd_24hr").get(); + volume_24h_usd = std::to_string(volume_node.get()); SPDLOG_INFO("{} volume usd: {}", ticker_reversed, volume_24h_usd); } + else if (volume_node.is_null()) + { + SPDLOG_WARN("Volume value is null for {}", ticker); + } + else + { + SPDLOG_WARN("Volume value is not a number for {}: {}", ticker, volume_node.type_name()); + } } else { - SPDLOG_WARN("Empty 24hr volume data for {}", defi_ticker_stats.dump(4)); + SPDLOG_WARN("No volume data available for {}", ticker); } return volume_24h_usd; } + + std::string + global_defi_stats_service::get_trades_24h(const std::string& base, const std::string& quote) const + { + std::string trades_24h = "0"; + auto ticker = base + "_" + quote; + auto ticker_reversed = quote + "_" + base; + SPDLOG_INFO("Getting 24hr trade data for {}", ticker); + + // Check if base/quote are the same + if (base == quote) + { + SPDLOG_INFO("Base/quote must be different, no volume data for {}", ticker); + return trades_24h; + } + + // Check if defi_stats_volumes is valid + auto defi_stats_volumes = m_defi_stats_volumes.get(); + if (!defi_stats_volumes.is_object()) + { + SPDLOG_WARN("Invalid defi stats volumes data."); + return trades_24h; + } + + // Check if volumes key exists + if (!defi_stats_volumes.contains("volumes")) + { + SPDLOG_WARN("No volumes data available."); + return trades_24h; + } + + // Extract ticker trade_volume_usd safely + if (defi_stats_volumes.at("volumes").contains(ticker)) + { + auto trades_node = defi_stats_volumes["volumes"][ticker]["ALL"]["trades_24hr"]; + if (trades_node.is_number()) + { + trades_24h = std::to_string(trades_node.get()); + SPDLOG_INFO("{} trades_24h: {}", ticker, trades_24h); + } + else if (trades_node.is_null()) + { + SPDLOG_WARN("Trades value is null for {}", ticker); + } + else + { + SPDLOG_WARN("Trades value is not a number for {}: {}", ticker, trades_node.type_name()); + } + } + else if (defi_stats_volumes["volumes"].contains(ticker_reversed)) + { + auto trades_node = defi_stats_volumes["volumes"][ticker_reversed]["ALL"]["trades_24hr"]; + if (trades_node.is_number()) + { + trades_24h = std::to_string(trades_node.get()); + SPDLOG_INFO("{} trades_24h: {}", ticker_reversed, trades_24h); + } + else if (trades_node.is_null()) + { + SPDLOG_WARN("Trades value is null for {}", ticker); + } + else + { + SPDLOG_WARN("Trades value is not a number for {}: {}", ticker, trades_node.type_name()); + } + } + else + { + SPDLOG_WARN("No trades data available for {}", ticker); + } + return trades_24h; + } } // namespace atomic_dex diff --git a/src/core/atomicdex/services/price/defi.stats.hpp b/src/core/atomicdex/services/price/defi.stats.hpp index 61941aec41..de626da1df 100644 --- a/src/core/atomicdex/services/price/defi.stats.hpp +++ b/src/core/atomicdex/services/price/defi.stats.hpp @@ -24,18 +24,18 @@ namespace atomic_dex::mm2 { - struct defi_ticker_stats_answer + struct defi_stats_volumes_answer { nlohmann::json result; int status_code; }; - void from_json(const nlohmann::json& j, defi_ticker_stats_answer& answer); + void from_json(const nlohmann::json& j, defi_stats_volumes_answer& answer); } // namespace atomic_dex::mm2 namespace atomic_dex { - using t_defi_ticker_stats_answer = mm2::defi_ticker_stats_answer; + using t_defi_stats_volumes_answer = mm2::defi_stats_volumes_answer; } // namespace atomic_dex namespace atomic_dex @@ -49,7 +49,7 @@ namespace atomic_dex //! Private member fields ag::ecs::system_manager& m_system_manager; - t_json_synchronized m_defi_ticker_stats; + t_json_synchronized m_defi_stats_volumes; t_defi_stats_time_point m_update_clock; //! private functions @@ -67,6 +67,7 @@ namespace atomic_dex //! Public API void process_defi_stats(); + std::string get_trades_24h(const std::string& base, const std::string& quote) const; std::string get_volume_24h_usd(const std::string& base, const std::string& quote) const; From 4ae90fe22be816aa27ebaf19ed94db9d419a6a6d Mon Sep 17 00:00:00 2001 From: smk762 Date: Fri, 29 Mar 2024 00:49:43 +0800 Subject: [PATCH 03/26] tabbed orderbook / bestorders --- .../Dex/Exchange/ProView/TradingInfo/Main.qml | 10 +-- .../Dex/Exchange/Trade/Market.qml | 89 +++++++++++++++++++ .../Dex/Exchange/Trade/ProView.qml | 45 ++-------- .../Dex/Exchange/Trade/Trade.qml | 3 +- .../Trade/Trading/TradeViewHeader.qml | 9 +- 5 files changed, 100 insertions(+), 56 deletions(-) create mode 100644 atomic_defi_design/Dex/Exchange/Trade/Market.qml diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml index 062063bfbe..cb6f0d4425 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml @@ -10,17 +10,11 @@ import "../../../Components" import "../../Trade" import "../../ProView" -Widget +ColumnLayout { - width: 450 + Layout.preferredWidth: 450 property alias currentIndex: tabView.currentIndex - title: qsTr("Trading Information") - - background: null - margins: 0 - - Qaterial.LatoTabBar { id: tabView diff --git a/atomic_defi_design/Dex/Exchange/Trade/Market.qml b/atomic_defi_design/Dex/Exchange/Trade/Market.qml new file mode 100644 index 0000000000..2940068ecf --- /dev/null +++ b/atomic_defi_design/Dex/Exchange/Trade/Market.qml @@ -0,0 +1,89 @@ +import QtQuick 2.15 +import QtQuick.Layouts 1.15 +import QtQuick.Controls 2.15 + +import Qaterial 1.0 as Qaterial + +import Dex.Themes 1.0 as Dex +import "../../Components" +import "../../Constants" + +// OrderBook / Component import +import "OrderBook/" as OrderBook + +// Best Order +import "BestOrder/" as BestOrder + + +ColumnLayout +{ + Layout.minimumWidth: 350 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignTop + property alias currentIndex: marketTabView.currentIndex + + Qaterial.LatoTabBar + { + id: marketTabView + property int orderbook: 0 + property int best_orders: 1 + + background: null + Layout.leftMargin: 6 + + Qaterial.LatoTabButton + { + text: qsTr("Orderbook") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor + } + Qaterial.LatoTabButton + { + text: qsTr("Best Orders") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor + } + } + + Rectangle + { + Layout.fillHeight: true + color: Dex.CurrentTheme.floatingBackgroundColor + radius: 10 + Layout.preferredWidth: 350 + + Qaterial.SwipeView + { + id: marketSwipeView + clip: true + interactive: false + currentIndex: marketTabView.currentIndex + anchors.fill: parent + + onCurrentIndexChanged: + { + marketSwipeView.currentItem.update(); + } + + OrderBook.Vertical + { + id: orderBook + Layout.fillHeight: true + Layout.fillWidth: true + } + + // Best Orders + BestOrder.List + { + id: bestOrders + Layout.fillHeight: true + Layout.fillWidth: true + } + } + } +} diff --git a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml index 0483903ffb..9550a275fc 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml @@ -42,8 +42,7 @@ RowLayout property alias tickerSelectors: selectors property alias trInfo: tradingInfo - property alias orderBook: orderBook - property alias bestOrders: bestOrders + property alias marketsOrderBook: marketsOrderBook property alias placeOrderForm: placeOrderForm function selectOrder( @@ -112,20 +111,15 @@ RowLayout ColumnLayout { Layout.alignment: Qt.AlignTop - Layout.minimumWidth: selectors.visible || tradingInfo.visible ? 450 : -1 Layout.maximumWidth: (!orderBook.visible && !bestOrders.visible) || (!placeOrderForm.visible) ? -1 : 450 - Layout.fillWidth: true - Layout.fillHeight: true - spacing: 10 // Ticker selectors. TickerSelectors { id: selectors - Layout.fillWidth: true Layout.preferredHeight: 70 } @@ -134,47 +128,20 @@ RowLayout TradingInfo.Main { id: tradingInfo - - Layout.fillWidth: true + Layout.maximumWidth: 450 Layout.fillHeight: true - - resizable: false } } - WidgetContainer + // Best Orders & Order Book + Market { - property real _orderBookHeightRatio: 0.65 - property real _bestOrdersHeightRatio: 0.35 - - Layout.minimumWidth: orderBook.visible || bestOrders.visible ? 350 : -1 + id: marketsOrderBook + Layout.maximumWidth: 350 Layout.fillWidth: true Layout.fillHeight: true Layout.alignment: Qt.AlignTop spacing: 4 - - onHeightChanged: - { - orderBook.height = getHeight(_orderBookHeightRatio); - bestOrders.height = getHeight(_bestOrdersHeightRatio); - } - - OrderBook.Vertical - { - id: orderBook - - width: parent.width - minHeight: 320 - } - - // Best Orders - BestOrder.List - { - id: bestOrders - - width: parent.width - minHeight: 140 - } } // Place order form. diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml index 1923050189..a102ecb8ce 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml @@ -172,8 +172,7 @@ Item proViewTickerSelectors: proView.tickerSelectors proViewTrInfo: proView.trInfo - proViewOrderBook: proView.orderBook - proViewBestOrders: proView.bestOrders + proViewMarketsOrderBook: proView.marketsOrderBook proViewPlaceOrderForm: proView.placeOrderForm } diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml b/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml index 8cc01d06d4..be41d57a74 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml @@ -21,8 +21,7 @@ Item // property var proViewChart property var proViewTickerSelectors property var proViewTrInfo - property var proViewOrderBook - property var proViewBestOrders + property var proViewMarketsOrderBook property var proViewPlaceOrderForm Item @@ -131,11 +130,7 @@ Item HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - CheckEye { text: qsTr("Order Book"); target: proViewOrderBook } - - HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - - CheckEye { text: qsTr("Best Orders"); target: proViewBestOrders } + CheckEye { text: qsTr("Markets"); target: proViewMarketsOrderBook } HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } From f67e3be32f2cc93e9f2efa63ed138cfef1a4fa13 Mon Sep 17 00:00:00 2001 From: smk762 Date: Fri, 29 Mar 2024 19:24:05 +0800 Subject: [PATCH 04/26] fix missing cancel button for own orders on orderbook --- .../Exchange/Trade/OrderBook/ListDelegate.qml | 83 +++++++++---------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml index 5ce557fc6b..e26bdbb54c 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml @@ -35,6 +35,7 @@ Item color: Qaterial.Colors.amber } + // Insufficient funds tooltip DexLabel { id: tooltip_text @@ -101,6 +102,7 @@ Item anchors.fill: parent hoverEnabled: true + // Populate foirm with selected order onClicked: { if (is_mine) return @@ -119,6 +121,7 @@ Item } } + // Highlight row on mouseover AnimatedRectangle { visible: mouse_area.containsMouse @@ -128,6 +131,7 @@ Item opacity: 0.1 } + // Dot on the left side of the row to indicate own order Rectangle { anchors.verticalCenter: parent.verticalCenter @@ -161,14 +165,16 @@ Item } } + // Price, Qty & Total text values Row { id: row anchors.fill: parent anchors.horizontalCenter: parent.horizontalCenter onWidthChanged: progress.width = ((depth * 100) * (width + 40)) / 100 - spacing: 0 + spacing: 3 + // Price Dex.ElidableText { anchors.verticalCenter: parent.verticalCenter @@ -181,78 +187,71 @@ Item wrapMode: Text.NoWrap } - Item { width: parent.width * 0.01 } - // Quantity Dex.ElidableText { anchors.verticalCenter: parent.verticalCenter width: parent.width * 0.37 + rightPadding: (is_mine) && (mouse_area.containsMouse || cancel_button_orderbook.containsMouse) ? 24 : 0 text: { new BigNumber(base_max_volume).toFixed(6) } font.family: DexTypo.fontFamily font.pixelSize: 12 horizontalAlignment: Text.AlignRight onTextChanged: depth_bar.width = ((depth * 100) * (mouse_area.width + 40)) / 100 wrapMode: Text.NoWrap + Behavior on rightPadding { NumberAnimation { duration: 150 } } } - Item { width: parent.width * 0.01 } - // Total Dex.ElidableText { + id: total_text anchors.verticalCenter: parent.verticalCenter width: parent.width * 0.30 - rightPadding: (is_mine) && (mouse_area.containsMouse || cancel_button.containsMouse) ? 30 : 0 + rightPadding: (is_mine) && (mouse_area.containsMouse || cancel_button_orderbook.containsMouse) ? 24 : 0 font.family: DexTypo.fontFamily font.pixelSize: 12 text: { new BigNumber(total).toFixed(6) } horizontalAlignment: Text.AlignRight wrapMode: Text.NoWrap - Behavior on rightPadding { NumberAnimation { duration: 150 } } } - } - } - Qaterial.ColorIcon - { - id: cancel_button_text - property bool requested_cancel: false - - visible: is_mine && !requested_cancel - - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: 1 - anchors.right: parent.right - anchors.rightMargin: mouse_area.containsMouse || cancel_button.containsMouse ? 12 : 6 - - Behavior on iconSize - { - NumberAnimation + // Cancel button + Item { - duration: 200 - } - } + width: is_mine && mouse_area.containsMouse ? 24 : 0 + visible: is_mine && total_text.rightPadding == 24 + height: parent.height + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right - iconSize: mouse_area.containsMouse || cancel_button.containsMouse? 16 : 0 + Qaterial.FlatButton + { + id: cancel_button_orderbook + anchors.centerIn: parent + anchors.fill: parent - color: cancel_button.containsMouse ? - Qaterial.Colors.red : mouse_area.containsMouse ? - DexTheme.foregroundColor: Qaterial.Colors.red + hoverEnabled: true - DefaultMouseArea - { - id: cancel_button - anchors.fill: parent - hoverEnabled: true + onClicked: if (details) cancelOrder(details.order_id) - onClicked: - { - if (!is_mine) return - - cancel_button_text.requested_cancel = true - cancelOrder(uuid) + Behavior on scale + { + NumberAnimation + { + duration: 200 + } + } + Qaterial.ColorIcon + { + anchors.centerIn: parent + iconSize: mouse_area.containsMouse? 16 : 0 + color: Dex.CurrentTheme.warningColor + source: Qaterial.Icons.close + scale: parent.visible ? 1 : 0 + } + } } } } From e2e0b3f3b74f30b7bac80d5ed03bb04a3607e915 Mon Sep 17 00:00:00 2001 From: smk762 Date: Sun, 31 Mar 2024 19:00:15 +0800 Subject: [PATCH 05/26] Use layouts for orderbook columns --- .../Exchange/Trade/OrderBook/ListDelegate.qml | 89 ++++++++++--------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml index e26bdbb54c..2e21b85061 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml @@ -102,7 +102,7 @@ Item anchors.fill: parent hoverEnabled: true - // Populate foirm with selected order + // Populate form with selected order onClicked: { if (is_mine) return @@ -131,17 +131,6 @@ Item opacity: 0.1 } - // Dot on the left side of the row to indicate own order - Rectangle - { - anchors.verticalCenter: parent.verticalCenter - width: 6 - height: 6 - radius: width / 2 - visible: is_mine - color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor - } - // Progress bar Rectangle { @@ -166,90 +155,108 @@ Item } // Price, Qty & Total text values - Row + RowLayout { id: row anchors.fill: parent - anchors.horizontalCenter: parent.horizontalCenter onWidthChanged: progress.width = ((depth * 100) * (width + 40)) / 100 spacing: 3 + // Dot on the left side of the row to indicate own order + Rectangle + { + Layout.leftMargin: 6 + Layout.alignment: Qt.AlignVCenter + opacity: is_mine ? 1 : 0 + width: 6 + height: 6 + radius: 3 + color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor + } + // Price Dex.ElidableText { - anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.31 + Layout.fillHeight: true + Layout.minimumWidth: 90 + Layout.alignment: Qt.AlignVCenter text: { new BigNumber(price).toFixed(8) } font.family: DexTypo.fontFamily font.pixelSize: 12 color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter wrapMode: Text.NoWrap } // Quantity Dex.ElidableText { - anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.37 - rightPadding: (is_mine) && (mouse_area.containsMouse || cancel_button_orderbook.containsMouse) ? 24 : 0 + Layout.fillHeight: true + Layout.minimumWidth: 90 + Layout.alignment: Qt.AlignVCenter text: { new BigNumber(base_max_volume).toFixed(6) } font.family: DexTypo.fontFamily font.pixelSize: 12 horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter onTextChanged: depth_bar.width = ((depth * 100) * (mouse_area.width + 40)) / 100 wrapMode: Text.NoWrap - Behavior on rightPadding { NumberAnimation { duration: 150 } } } // Total Dex.ElidableText { id: total_text - anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.30 - rightPadding: (is_mine) && (mouse_area.containsMouse || cancel_button_orderbook.containsMouse) ? 24 : 0 + Layout.fillHeight: true + Layout.minimumWidth: 90 + Layout.fillWidth: true + Layout.alignment: Qt.AlignVCenter font.family: DexTypo.fontFamily font.pixelSize: 12 text: { new BigNumber(total).toFixed(6) } horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter wrapMode: Text.NoWrap - Behavior on rightPadding { NumberAnimation { duration: 150 } } } + // Cancel button Item { - width: is_mine && mouse_area.containsMouse ? 24 : 0 - visible: is_mine && total_text.rightPadding == 24 - height: parent.height - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right + id: cancel_flat_btn + Layout.fillHeight: true + width: 30 + Layout.alignment: Qt.AlignVCenter + + MouseArea + { + id: cancel_mouse_area + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + } Qaterial.FlatButton { id: cancel_button_orderbook anchors.centerIn: parent anchors.fill: parent + opacity: is_mine ? 1 : 0 - hoverEnabled: true - - onClicked: if (details) cancelOrder(details.order_id) - - Behavior on scale - { - NumberAnimation - { - duration: 200 - } + onClicked: { + if (uuid) cancelOrder(uuid); } + Qaterial.ColorIcon { anchors.centerIn: parent - iconSize: mouse_area.containsMouse? 16 : 0 + iconSize: 16 color: Dex.CurrentTheme.warningColor source: Qaterial.Icons.close - scale: parent.visible ? 1 : 0 + visible: is_mine + scale: is_mine && mouse_area.containsMouse ? 1 : 0 + Behavior on scale { NumberAnimation { duration: 150 } } } } } From d960923db6bde0a772a6e8e7f0acd2d5d8e4f937 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 1 Apr 2024 13:39:50 +0800 Subject: [PATCH 06/26] add outgoing/incoming text to orders modal --- atomic_defi_design/Dex/Components/PairItemBadge.qml | 10 ++++++++++ atomic_defi_design/Dex/Constants/DexTypo.qml | 7 +++++++ .../Dex/Exchange/ProView/TradingInfo/OrderModal.qml | 1 + 3 files changed, 18 insertions(+) diff --git a/atomic_defi_design/Dex/Components/PairItemBadge.qml b/atomic_defi_design/Dex/Components/PairItemBadge.qml index 4fec7de383..ceeaa3c0b0 100644 --- a/atomic_defi_design/Dex/Components/PairItemBadge.qml +++ b/atomic_defi_design/Dex/Components/PairItemBadge.qml @@ -24,11 +24,21 @@ DexRectangle property int padding: 0 property alias middle_text: middle_line.text_value property alias bottom_text: bottom_line.text_value + property bool is_left: false Layout.fillHeight: true Layout.fillWidth: true Layout.leftMargin: 10 Layout.rightMargin: 20 + Dex.Text{ + anchors.bottom: parent.top + anchors.bottomMargin: 5 + anchors.horizontalCenter: parent.horizontalCenter + text: is_left ? "Outgoing" : "Incoming" + font: Dex.DexTypo.italic12 + color: Dex.CurrentTheme.foregroundColor2 + } + RowLayout { anchors.fill: parent diff --git a/atomic_defi_design/Dex/Constants/DexTypo.qml b/atomic_defi_design/Dex/Constants/DexTypo.qml index 8df64967c7..1207047e87 100644 --- a/atomic_defi_design/Dex/Constants/DexTypo.qml +++ b/atomic_defi_design/Dex/Constants/DexTypo.qml @@ -154,6 +154,13 @@ QtObject { family: "Courier", weight: Font.Normal }) + property font italic12: Qt.font({ + pixelSize: 12 * fontDensity, + letterSpacing: 0.2, + family: fontFamily, + weight: Font.Normal, + italic: true + }) property font inputFieldFont: Qt.font({ pixelSize: (16 * DexTypo.fontDensity) * (Screen.pixelDensity / 160), letterSpacing: 0.5, diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml index 2c0f7854c1..2bdb8cf43c 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml @@ -66,6 +66,7 @@ MultipageModal PairItemBadge { + is_left: true ticker: details ? details.base_coin : "" fullname: details ? General.coinName(details.base_coin) : "" amount: details ? details.base_amount : "" From 42aca12bf5bdd69dba5ff94af65cf2a99bfad096 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 1 Apr 2024 15:41:22 +0800 Subject: [PATCH 07/26] rm logspam --- src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.cpp | 2 -- .../atomicdex/services/price/orderbook.scanner.service.cpp | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.cpp b/src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.cpp index f80fa1ec55..9831628f46 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.cpp +++ b/src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.cpp @@ -40,7 +40,6 @@ namespace atomic_dex::mm2 if (j.contains("result")) { // Not sure how why where it is being returned in this format - SPDLOG_DEBUG("orderbook_result_rpc: result"); j.at("result").at("rel").get_to(resp.rel); j.at("result").at("num_asks").get_to(resp.numasks); j.at("result").at("num_bids").get_to(resp.numbids); @@ -52,7 +51,6 @@ namespace atomic_dex::mm2 } else { - SPDLOG_DEBUG("orderbook_result_rpc: base"); j.at("base").get_to(resp.base); j.at("rel").get_to(resp.rel); j.at("num_asks").get_to(resp.numasks); diff --git a/src/core/atomicdex/services/price/orderbook.scanner.service.cpp b/src/core/atomicdex/services/price/orderbook.scanner.service.cpp index 823ec28708..b49b3b7d89 100644 --- a/src/core/atomicdex/services/price/orderbook.scanner.service.cpp +++ b/src/core/atomicdex/services/price/orderbook.scanner.service.cpp @@ -65,7 +65,7 @@ namespace atomic_dex { SPDLOG_ERROR("error: bad answer json for process_best_orders: {}", rpc.error->error); this->m_bestorders_busy = false; - SPDLOG_ERROR("Triggering [process_orderbook_finished]: true"); + // SPDLOG_ERROR("Triggering [process_orderbook_finished]: true"); this->dispatcher_.trigger(true); } else @@ -75,7 +75,7 @@ namespace atomic_dex this->m_best_orders_infos = rpc.result.value(); } this->m_bestorders_busy = false; - SPDLOG_ERROR("Triggering [process_orderbook_finished]: false"); + // SPDLOG_ERROR("Triggering [process_orderbook_finished]: false"); this->dispatcher_.trigger(false); emit trading_pg.get_orderbook_wrapper()->bestOrdersBusyChanged(); } From 955a0919c0e3406f8db1684be8d0aae292134113 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 1 Apr 2024 15:42:25 +0800 Subject: [PATCH 08/26] exception avoidance --- src/core/atomicdex/services/price/global.provider.cpp | 5 +++++ src/core/atomicdex/utilities/safe.float.cpp | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/atomicdex/services/price/global.provider.cpp b/src/core/atomicdex/services/price/global.provider.cpp index 1da473e6a7..93e57b3a6c 100644 --- a/src/core/atomicdex/services/price/global.provider.cpp +++ b/src/core/atomicdex/services/price/global.provider.cpp @@ -312,6 +312,11 @@ namespace atomic_dex { try { + if (amount == "" || ticker == "" || currency == "") + { + return "0.00"; + } + auto& mm2_instance = m_system_manager.get_system(); const auto ticker_infos = mm2_instance.get_coin_info(ticker); diff --git a/src/core/atomicdex/utilities/safe.float.cpp b/src/core/atomicdex/utilities/safe.float.cpp index 62dea4f09a..05d924d736 100644 --- a/src/core/atomicdex/utilities/safe.float.cpp +++ b/src/core/atomicdex/utilities/safe.float.cpp @@ -19,12 +19,16 @@ safe_float(const std::string& from) { try { + if (from.empty()) + { + return t_float_50(0); + } t_float_50 out(boost::algorithm::replace_all_copy(from, ",", ".")); return out; } catch (const std::exception& error) { - SPDLOG_ERROR("exception caught when creating a floating point number: {}", error.what()); + SPDLOG_ERROR("exception caught when creating a floating point number from {}: {}", from, error.what()); //#if defined(linux) || defined(__APPLE__) // SPDLOG_ERROR("stacktrace: {}", boost::stacktrace::to_string(boost::stacktrace::stacktrace())); //#endif From af650fd942c4cbe92150601fc4506ab5811548ee Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 1 Apr 2024 15:43:01 +0800 Subject: [PATCH 09/26] add min/max vol to orders modal --- .../ProView/TradingInfo/OrderModal.qml | 20 +++++++++++++++++++ src/core/atomicdex/api/mm2/mm2.cpp | 3 ++- .../atomicdex/data/dex/qt.orders.data.hpp | 3 ++- src/core/atomicdex/models/qt.orders.model.cpp | 12 +++++++++++ src/core/atomicdex/models/qt.orders.model.hpp | 2 ++ .../models/qt.orders.proxy.model.cpp | 4 ++++ 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml index 2bdb8cf43c..df4d38f8a7 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml @@ -120,6 +120,26 @@ MultipageModal label.font.pixelSize: 13 } + // Min Vol + TextEditWithTitle + { + Layout.fillWidth: true + title: qsTr("Min Volume") + text: details ? details.min_volume + " " + details.base_coin : "" + label.font.pixelSize: 13 + visible: General.exists(details) && details.min_volume != "" + } + + // Max Vol + TextEditWithTitle + { + Layout.fillWidth: true + title: qsTr("Max Volume") + text: details ? details.max_volume + " " + details.base_coin : "" + label.font.pixelSize: 13 + visible: General.exists(details) && details.max_volume != "" + } + // Refund state TextEditWithTitle { diff --git a/src/core/atomicdex/api/mm2/mm2.cpp b/src/core/atomicdex/api/mm2/mm2.cpp index 0971464177..794fadb2c8 100644 --- a/src/core/atomicdex/api/mm2/mm2.cpp +++ b/src/core/atomicdex/api/mm2/mm2.cpp @@ -293,7 +293,8 @@ namespace atomic_dex::mm2 .is_swap = false, .is_cancellable = value.at("cancellable").get(), .is_recoverable = false, - .min_volume = is_maker ? QString::fromStdString(value.at("min_base_vol").get()) : std::optional(std::nullopt), + .min_volume = is_maker ? QString::fromStdString(value.at("min_base_vol").get()) : "", + .max_volume = is_maker ? QString::fromStdString(value.at("max_base_vol").get()) : "", .conf_settings = conf_settings}; if (action.empty() && contents.order_type == "maker") { diff --git a/src/core/atomicdex/data/dex/qt.orders.data.hpp b/src/core/atomicdex/data/dex/qt.orders.data.hpp index 27f0859ed2..d5723bb8f4 100644 --- a/src/core/atomicdex/data/dex/qt.orders.data.hpp +++ b/src/core/atomicdex/data/dex/qt.orders.data.hpp @@ -85,7 +85,8 @@ namespace atomic_dex::mm2 bool is_swap_active{false}; //! Only available for maker order - std::optional min_volume{std::nullopt}; + QString min_volume; + QString max_volume; std::optional conf_settings{std::nullopt}; }; } // namespace atomic_dex::mm2 diff --git a/src/core/atomicdex/models/qt.orders.model.cpp b/src/core/atomicdex/models/qt.orders.model.cpp index 72ba1c6444..462d8f8d8d 100644 --- a/src/core/atomicdex/models/qt.orders.model.cpp +++ b/src/core/atomicdex/models/qt.orders.model.cpp @@ -82,6 +82,12 @@ namespace atomic_dex case RelCoinAmountCurrentCurrencyRole: item.rel_amount_fiat = value.toString(); break; + case MinVolumeRole: + item.min_volume = value.toString(); + break; + case MaxVolumeRole: + item.max_volume = value.toString(); + break; case OrderTypeRole: item.order_type = value.toString(); break; @@ -166,6 +172,10 @@ namespace atomic_dex return item.rel_amount; case RelCoinAmountCurrentCurrencyRole: return item.rel_amount_fiat; + case MinVolumeRole: + return item.min_volume; + case MaxVolumeRole: + return item.max_volume; case OrderTypeRole: return item.order_type; case HumanDateRole: @@ -233,6 +243,8 @@ namespace atomic_dex {BaseCoinAmountCurrentCurrencyRole, "base_amount_current_currency"}, {RelCoinAmountRole, "rel_amount"}, {RelCoinAmountCurrentCurrencyRole, "rel_amount_current_currency"}, + {MinVolumeRole, "min_volume"}, + {MaxVolumeRole, "max_volume"}, {OrderTypeRole, "type"}, {IsMakerRole, "is_maker"}, {HumanDateRole, "date"}, diff --git a/src/core/atomicdex/models/qt.orders.model.hpp b/src/core/atomicdex/models/qt.orders.model.hpp index bb00288a28..e58568d05b 100644 --- a/src/core/atomicdex/models/qt.orders.model.hpp +++ b/src/core/atomicdex/models/qt.orders.model.hpp @@ -63,6 +63,8 @@ namespace atomic_dex RelCoinAmountRole, RelCoinAmountCurrentCurrencyRole, OrderTypeRole, + MinVolumeRole, + MaxVolumeRole, IsMakerRole, HumanDateRole, UnixTimestampRole, diff --git a/src/core/atomicdex/models/qt.orders.proxy.model.cpp b/src/core/atomicdex/models/qt.orders.proxy.model.cpp index f66ce759b8..bd6ec71636 100644 --- a/src/core/atomicdex/models/qt.orders.proxy.model.cpp +++ b/src/core/atomicdex/models/qt.orders.proxy.model.cpp @@ -55,6 +55,10 @@ namespace atomic_dex break; case orders_model::RelCoinAmountCurrentCurrencyRole: break; + case orders_model::MinVolumeRole: + break; + case orders_model::MaxVolumeRole: + break; case orders_model::OrderTypeRole: break; case orders_model::IsMakerRole: From a952f3d8ed330357cdc42f83859c20dee0e47f38 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 1 Apr 2024 17:07:09 +0800 Subject: [PATCH 10/26] open lcw when chart is clicked --- atomic_defi_design/Dex/Exchange/ProView/Chart.qml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/atomic_defi_design/Dex/Exchange/ProView/Chart.qml b/atomic_defi_design/Dex/Exchange/ProView/Chart.qml index 30fc49a4cd..69480206f4 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/Chart.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/Chart.qml @@ -70,6 +70,7 @@ Item transform: scale(${Math.min(scale_x, scale_y)}); transform-origin: top left; } + a { pointer-events: none; }
@@ -226,6 +227,16 @@ Item } } + MouseArea { + id: chart_mousearea + anchors.fill: webEngineViewPlaceHolder + onClicked: { + if (webEngineView.visible) { + Qt.openUrlExternally("https://www.livecoinwatch.com") + } + } + } + Connections { target: app From 22df4dd9d32a7b3484f7a6b71e3631fbf1c9f052 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 1 Apr 2024 23:57:24 +0800 Subject: [PATCH 11/26] allow testcoins through filter in simple dex view --- src/core/atomicdex/models/qt.orderbook.proxy.model.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp b/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp index 28b47ab518..f41ae7dfd8 100644 --- a/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp +++ b/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp @@ -167,6 +167,10 @@ namespace atomic_dex { return false; } + if (coin_info.is_testnet) + { + break; + } if (is_cex_id_available && (rates > 100 || fiat_price <= 0 || ((safe_float(volume) < limit) && coin_info.coin_type != CoinType::SmartChain))) { return false; From cc7ba3e74f4b8e0cd3eee408b0e4a56934a590aa Mon Sep 17 00:00:00 2001 From: smk762 Date: Tue, 2 Apr 2024 17:25:49 +0800 Subject: [PATCH 12/26] isolate testcoins in bestorders --- .../Exchange/Trade/BestOrder/ListDelegate.qml | 7 ++-- src/core/atomicdex/config/coins.cfg.cpp | 32 +++++++++---------- .../models/qt.orderbook.proxy.model.cpp | 25 +++++++++------ .../atomicdex/services/mm2/mm2.service.cpp | 2 +- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml index e5893f2e31..bcf1fa9c30 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml @@ -14,8 +14,7 @@ import AtomicDEX.MarketMode 1.0 Item { id: _control - - property bool coinEnable: API.app.portfolio_pg.global_cfg_mdl.get_coin_info(coin).is_enabled + property bool _isCoinEnabled: API.app.portfolio_pg.global_cfg_mdl.get_coin_info(coin).is_enabled property bool isAsk AnimatedRectangle @@ -46,7 +45,7 @@ Item height: 24 anchors.verticalCenter: parent.verticalCenter source: General.coinIcon(coin) - opacity: !_control.coinEnable? .1 : 1 + opacity: !_control._isCoinEnabled? .1 : 1 } Dex.Text @@ -137,7 +136,7 @@ Item { if (API.app.enable_coins([coin]) === true) { - _control.coinEnable = true; + _control._isCoinEnabled = true; _tooltip.close(); } else { diff --git a/src/core/atomicdex/config/coins.cfg.cpp b/src/core/atomicdex/config/coins.cfg.cpp index 1f846b5376..18aa67a1d5 100644 --- a/src/core/atomicdex/config/coins.cfg.cpp +++ b/src/core/atomicdex/config/coins.cfg.cpp @@ -286,21 +286,21 @@ namespace atomic_dex { case CoinType::QRC20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "tQTUM" : "QTUM"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "tQTUM" : "QTUM"; break; case CoinType::ERC20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "ETHR" : "ETH"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "ETHR" : "ETH"; cfg.is_erc_family = true; break; case CoinType::BEP20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "BNBT" : "BNB"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "BNBT" : "BNB"; cfg.is_erc_family = true; break; case CoinType::PLG20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "MATICTEST" : "MATIC"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "MATICTEST" : "MATIC"; cfg.is_erc_family = true; break; case CoinType::Optimism: @@ -320,62 +320,62 @@ namespace atomic_dex break; case CoinType::AVX20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "AVAXT" : "AVAX"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "AVAXT" : "AVAX"; cfg.is_erc_family = true; break; case CoinType::FTM20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "FTMT" : "FTM"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "FTMT" : "FTM"; cfg.is_erc_family = true; break; case CoinType::HRC20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "ONET" : "ONE"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "ONET" : "ONE"; cfg.is_erc_family = true; break; case CoinType::Ubiq: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "UBQT" : "UBQ"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "UBQT" : "UBQ"; cfg.is_erc_family = true; break; case CoinType::KRC20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "KCST" : "KCS"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "KCST" : "KCS"; cfg.is_erc_family = true; break; case CoinType::Moonriver: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "MOVRT" : "MOVR"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "MOVRT" : "MOVR"; cfg.is_erc_family = true; break; case CoinType::Moonbeam: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "GLMRT" : "GLMR"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "GLMRT" : "GLMR"; cfg.is_erc_family = true; break; case CoinType::HecoChain: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "HTT" : "HT"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "HTT" : "HT"; cfg.is_erc_family = true; break; case CoinType::SmartBCH: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "SBCHT" : "SBCH"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "SBCHT" : "SBCH"; cfg.is_erc_family = true; break; case CoinType::EthereumClassic: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "ETCT" : "ETC"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "ETCT" : "ETC"; cfg.is_erc_family = true; break; case CoinType::RSK: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "RBTCT" : "RBTC"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "RBTCT" : "RBTC"; cfg.is_erc_family = true; break; case CoinType::SLP: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "tBCH" : "BCH"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "tBCH" : "BCH"; break; case CoinType::TENDERMINT: cfg.has_parent_fees_ticker = true; diff --git a/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp b/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp index f41ae7dfd8..6117bf3eb9 100644 --- a/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp +++ b/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp @@ -155,27 +155,34 @@ namespace atomic_dex case orderbook_model::kind::bids: break; case orderbook_model::kind::best_orders: - t_float_50 rates = safe_float(this->sourceModel()->data(idx, orderbook_model::CEXRatesRole).toString().toStdString()); - t_float_50 fiat_price = safe_float(this->sourceModel()->data(idx, orderbook_model::PriceFiatRole).toString().toStdString()); - std::string ticker = this->sourceModel()->data(idx, orderbook_model::CoinRole).toString().toStdString(); - const auto& provider = this->m_system_mgr.get_system(); - const auto coin_info = this->m_system_mgr.get_system().get_global_cfg()->get_coin_info(ticker); t_float_50 limit("10000"); + t_float_50 rates = safe_float(this->sourceModel()->data(idx, orderbook_model::CEXRatesRole).toString().toStdString()); + t_float_50 fiat_price = safe_float(this->sourceModel()->data(idx, orderbook_model::PriceFiatRole).toString().toStdString()); bool is_cex_id_available = this->sourceModel()->data(idx, orderbook_model::HaveCEXIDRole).toBool(); - const auto volume = provider.get_total_volume(utils::retrieve_main_ticker(ticker)); + const auto& provider = this->m_system_mgr.get_system(); + std::string ticker = this->sourceModel()->data(idx, orderbook_model::CoinRole).toString().toStdString(); + const auto coin_info = this->m_system_mgr.get_system().get_global_cfg()->get_coin_info(ticker); + const auto volume = provider.get_total_volume(utils::retrieve_main_ticker(ticker)); + std::string left_ticker = this->m_system_mgr.get_system().get_market_pairs_mdl()->get_left_selected_coin().toStdString(); + const auto left_coin_info = this->m_system_mgr.get_system().get_global_cfg()->get_coin_info(left_ticker); + if (coin_info.ticker.empty() || coin_info.wallet_only) //< this means it's not present in our cfg - skipping { return false; } - if (coin_info.is_testnet) + if (left_coin_info.is_testnet.value_or(false)) { - break; + if (coin_info.is_testnet.value_or(false)) + { + return true; + } + return false; } if (is_cex_id_available && (rates > 100 || fiat_price <= 0 || ((safe_float(volume) < limit) && coin_info.coin_type != CoinType::SmartChain))) { return false; } - break; + return true; } } diff --git a/src/core/atomicdex/services/mm2/mm2.service.cpp b/src/core/atomicdex/services/mm2/mm2.service.cpp index cccedaed77..aac8b30293 100644 --- a/src/core/atomicdex/services/mm2/mm2.service.cpp +++ b/src/core/atomicdex/services/mm2/mm2.service.cpp @@ -3019,7 +3019,7 @@ namespace atomic_dex const coin_config_t cfg = this->get_coin_info(ticker); if (cfg.coin_type == CoinType::QRC20) { - if (cfg.is_testnet.value()) + if (cfg.is_testnet.value_or(false)) { SPDLOG_INFO("{} is from testnet picking tQTUM electrum", ticker); servers = std::move(get_coin_info("tQTUM").electrum_urls.value()); From 3c908aecf0da3e0036d5ccf2d456646a33907552 Mon Sep 17 00:00:00 2001 From: smk762 Date: Wed, 3 Apr 2024 01:21:09 +0800 Subject: [PATCH 13/26] update dex pro layout --- .../Dex/Exchange/ProView/DexComboBoxLine.qml | 6 +- .../Exchange/ProView/PlaceOrderForm/Main.qml | 126 ++++-------------- .../ProView/SearchableTickerSelector.qml | 8 +- .../Dex/Exchange/ProView/TickerSelectors.qml | 24 ++-- .../Dex/Exchange/ProView/TradingInfo/Main.qml | 52 +++++++- .../MarketModeSelector.qml | 29 +++- .../Dex/Exchange/Trade/BestOrder/List.qml | 1 + .../Dex/Exchange/Trade/OrderBook/Vertical.qml | 1 + .../Dex/Exchange/Trade/ProView.qml | 24 +--- .../Dex/Exchange/Trade/Trade.qml | 1 - .../Trade/Trading/TradeViewHeader.qml | 16 +-- 11 files changed, 132 insertions(+), 156 deletions(-) rename atomic_defi_design/Dex/Exchange/ProView/{PlaceOrderForm => TradingInfo}/MarketModeSelector.qml (57%) diff --git a/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml b/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml index 7c3404f433..0d8269efb9 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml @@ -78,7 +78,7 @@ RowLayout Layout.preferredWidth: parent.width - 15 text_value: !details ? "" : - `${details.ticker}   ${details.name}` + `${details.ticker}
${details.name}` font.pixelSize: Style.textSizeSmall3 elide: Text.ElideRight wrapMode: Text.NoWrap @@ -96,7 +96,7 @@ RowLayout font: DexTypo.body2 wrapMode: Label.NoWrap ToolTip.text: coin_value - Component.onCompleted: font.pixelSize = 11.5 + Component.onCompleted: font.pixelSize = 11 } Dex.Text @@ -112,7 +112,7 @@ RowLayout font: DexTypo.body2 wrapMode: Label.NoWrap ToolTip.text: fiat_value - Component.onCompleted: font.pixelSize = 11.5 + Component.onCompleted: font.pixelSize = 11 } } } diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml index ca94aec96e..0c937d385c 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml @@ -18,7 +18,6 @@ Widget property bool show_waiting_for_trade_preimage: false; property var fees: API.app.trading_pg.fees property var preimage_rpc_busy: API.app.trading_pg.preimage_rpc_busy - property string protocolIcon: General.platformIcon(General.coinPlatform(left_ticker)) property var trade_preimage_error: fees.hasOwnProperty('error') ? fees["error"].split("] ").slice(-1) : "" readonly property bool trade_preimage_ready: fees.hasOwnProperty('base_transaction_fees_ticker') readonly property bool can_submit_trade: last_trading_error === TradingError.None @@ -68,90 +67,51 @@ Widget errors.text_value = "" } - // Market mode selector - RowLayout + OrderForm { - Layout.topMargin: 5 - Layout.bottomMargin: 2 + id: formBase + width: parent.width + height: 330 Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - height: 32 - - MarketModeSelector - { - Layout.alignment: Qt.AlignLeft - Layout.preferredWidth: (parent.width / 100) * 46 - Layout.preferredHeight: 32 - marketMode: MarketMode.Buy - ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) - } + } - Item { Layout.fillWidth: true } - MarketModeSelector - { - Layout.alignment: Qt.AlignRight - Layout.preferredWidth: (parent.width / 100) * 46 - Layout.preferredHeight: 32 - ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) - } - } + Item { Layout.fillHeight: true } - // Protocol text for platform tokens + // Error messages + // TODO: Move to toasts Item { - height: 32 - Layout.alignment: Qt.AlignHCenter + height: 55 Layout.preferredWidth: parent.width - visible: protocolIcon != "" - ColumnLayout + // Show errors + Dex.Text { - spacing: 2 + id: errors + visible: errors.text_value !== "" anchors.fill: parent anchors.centerIn: parent - - Dex.Text - { - id: protocolTitle - Layout.preferredWidth: parent.width - text_value: "Protocol:" - font.pixelSize: Style.textSizeSmall1 - horizontalAlignment: Text.AlignHCenter - color: Style.colorText2 - } - - RowLayout - { - id: protocol - Layout.alignment: Qt.AlignHCenter - - DefaultImage - { - id: protocolImg - source: protocolIcon - Layout.preferredHeight: 16 - Layout.preferredWidth: Layout.preferredHeight - } - - DexLabel - { - id: protocolText - text_value: General.getProtocolText(left_ticker) - wrapMode: DexLabel.NoWrap - font.pixelSize: Style.textSizeSmall1 - color: Style.colorText2 - } - } + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Style.textSizeSmall4 + color: Dex.CurrentTheme.warningColor + text_value: General.getTradingError( + last_trading_error, + curr_fee_info, + base_ticker, + rel_ticker, left_ticker, right_ticker) + elide: Text.ElideRight } } + Item { Layout.fillHeight: true } + // Order selected indicator Item { Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - height: 32 + Layout.preferredWidth: parent.width - 16 + height: 28 RowLayout { @@ -200,40 +160,6 @@ Widget } } - OrderForm - { - id: formBase - width: parent.width - height: 330 - Layout.alignment: Qt.AlignHCenter - } - - Item { Layout.fillHeight: true } - - // Error messages - Item - { - height: 55 - Layout.preferredWidth: parent.width - - // Show errors - Dex.Text - { - id: errors - visible: errors.text_value !== "" - anchors.fill: parent - anchors.centerIn: parent - horizontalAlignment: Text.AlignHCenter - font.pixelSize: Style.textSizeSmall4 - color: Dex.CurrentTheme.warningColor - text_value: General.getTradingError( - last_trading_error, - curr_fee_info, - base_ticker, - rel_ticker, left_ticker, right_ticker) - elide: Text.ElideRight - } - } TotalView { diff --git a/atomic_defi_design/Dex/Exchange/ProView/SearchableTickerSelector.qml b/atomic_defi_design/Dex/Exchange/ProView/SearchableTickerSelector.qml index 6bda8f68fe..68b621ef0d 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/SearchableTickerSelector.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/SearchableTickerSelector.qml @@ -18,13 +18,13 @@ Dex.ComboBoxWithSearchBar property string ticker property bool index_changed: false - height: 70 + height: 85 enabled: !block_everything textRole: "ticker" valueRole: "ticker" - popupMaxHeight: Math.min(model.rowCount() * 70 + 70, 600) + popupMaxHeight: Math.min(model.rowCount() * 85 + 85, 600) popupForceMaxHeight: true searchBar.visible: true @@ -34,7 +34,7 @@ Dex.ComboBoxWithSearchBar { id: _delegate width: control.width - height: visible ? 70 : 0 + height: visible ? 85 : 0 highlighted: control.highlightedIndex === index contentItem: DexComboBoxLine { details: model } @@ -52,7 +52,7 @@ Dex.ComboBoxWithSearchBar property int update_count: 0 property var prev_details - padding: 10 + padding: 8 function forceUpdateDetails() { diff --git a/atomic_defi_design/Dex/Exchange/ProView/TickerSelectors.qml b/atomic_defi_design/Dex/Exchange/ProView/TickerSelectors.qml index 6c52fed103..8b317cecba 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TickerSelectors.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TickerSelectors.qml @@ -6,9 +6,12 @@ import "../../Components" import "../../Constants" // Ticker selectors. -Row +RowLayout { id: selectors + Layout.topMargin: 8 + Layout.bottomMargin: 2 + Layout.alignment: Qt.AlignHCenter function renewIndex() { @@ -21,9 +24,8 @@ Row SearchableTickerSelector { id: selectorLeft - - width: 210 - height: parent.height + Layout.preferredWidth: 195 + Layout.preferredHeight: 85 left_side: true model: API.app.trading_pg.market_pairs_mdl.left_selection_box @@ -38,10 +40,12 @@ Row } } + Item { Layout.fillWidth: true } + SwapIcon { - width: 25 - anchors.verticalCenter: parent.verticalCenter + Layout.preferredHeight: 25 + Layout.alignment: Qt.AlignVCenter top_arrow_ticker: selectorLeft.ticker bottom_arrow_ticker: selectorRight.ticker hovered: swap_button.containsMouse @@ -59,13 +63,13 @@ Row } } + Item { Layout.fillWidth: true } + SearchableTickerSelector { id: selectorRight - - width: 210 - height: parent.height - + Layout.preferredWidth: 195 + Layout.preferredHeight: 85 left_side: false model: API.app.trading_pg.market_pairs_mdl.right_selection_box ticker: right_ticker diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml index cb6f0d4425..a6ab52038d 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml @@ -5,6 +5,8 @@ import QtQuick.Controls 2.15 import Qaterial 1.0 as Qaterial import Dex.Themes 1.0 as Dex +import Dex.Components 1.0 as Dex +import AtomicDEX.MarketMode 1.0 import "../../../Constants" import "../../../Components" import "../../Trade" @@ -13,6 +15,7 @@ import "../../ProView" ColumnLayout { Layout.preferredWidth: 450 + Layout.fillHeight: true property alias currentIndex: tabView.currentIndex Qaterial.LatoTabBar @@ -70,7 +73,53 @@ ColumnLayout { Layout.fillHeight: true Layout.fillWidth: true - spacing: 10 + Layout.topMargin: 8 + spacing: 8 + + // Ticker selectors. + TickerSelectors + { + id: selectors + Layout.preferredWidth: 435 + Layout.preferredHeight: 85 + Layout.leftMargin: 8 + Layout.rightMargin: 8 + } + + // Market mode selector + RowLayout + { + Layout.topMargin: 2 + Layout.bottomMargin: 2 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: 435 + height: 28 + + Item { Layout.fillWidth: true } + MarketModeSelector + { + Layout.alignment: Qt.AlignLeft + Layout.preferredWidth: 150 + Layout.preferredHeight: 28 + marketMode: MarketMode.Buy + ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + } + + Item { Layout.fillWidth: true } + + Item { Layout.fillWidth: true } + + MarketModeSelector + { + Layout.alignment: Qt.AlignRight + Layout.preferredWidth: 150 + Layout.preferredHeight: 28 + ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + } + Item { Layout.fillWidth: true } + } + + // Chart Chart { @@ -91,6 +140,7 @@ ColumnLayout Layout.rightMargin: 5 Layout.fillWidth: true Layout.fillHeight: true + width: 435 } } diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/MarketModeSelector.qml similarity index 57% rename from atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml rename to atomic_defi_design/Dex/Exchange/ProView/TradingInfo/MarketModeSelector.qml index b4ffbdbf17..799e0b8a15 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/MarketModeSelector.qml @@ -1,4 +1,5 @@ import QtQuick 2.12 +import QtQuick.Layouts 1.15 import App 1.0 import Dex.Themes 1.0 as Dex @@ -9,9 +10,10 @@ Rectangle { property int marketMode: Dex.MarketMode.Sell property string ticker: "" + property string protocolIcon: General.platformIcon(General.coinPlatform(left_ticker)) radius: 18 - opacity: marketMode != API.app.trading_pg.market_mode ? 0.1 : 1 + opacity: marketMode != API.app.trading_pg.market_mode ? 0.25: 1 gradient: Gradient { @@ -32,15 +34,28 @@ Rectangle position: 1 } } - - DefaultText + RowLayout { anchors.centerIn: parent - color: API.app.trading_pg.market_mode == marketMode ? Dex.CurrentTheme.gradientButtonTextEnabledColor : Dex.CurrentTheme.foregroundColor - text: + spacing: 8 + + DefaultText + { + color: API.app.trading_pg.market_mode == marketMode ? Dex.CurrentTheme.gradientButtonTextEnabledColor : Dex.CurrentTheme.foregroundColor + text: + { + if (marketMode == Dex.MarketMode.Sell) qsTr("Sell %1", "TICKER").arg(ticker) + else qsTr("Buy %1", "TICKER").arg(ticker) + } + } + + DefaultImage { - if (marketMode == Dex.MarketMode.Sell) qsTr("Sell %1", "TICKER").arg(ticker) - else qsTr("Buy %1", "TICKER").arg(ticker) + id: protocolImg + visible: protocolIcon != "" + source: protocolIcon + Layout.preferredHeight: protocolIcon != "" ? 16 : 0 + Layout.preferredWidth: Layout.preferredHeight } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml index 85a7be4ebe..e179c4c8b6 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml @@ -17,6 +17,7 @@ Widget title: qsTr("Best Orders") margins: 10 spacing: 10 + collapsable: false Header { diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml index 4a572f8b9d..2b0a3bdedf 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml @@ -18,6 +18,7 @@ Widget margins: 8 spacing: 2 + collapsable: false Header { diff --git a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml index 9550a275fc..877e443b3c 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml @@ -40,7 +40,6 @@ RowLayout { id: form - property alias tickerSelectors: selectors property alias trInfo: tradingInfo property alias marketsOrderBook: marketsOrderBook property alias placeOrderForm: placeOrderForm @@ -108,29 +107,14 @@ RowLayout } } - ColumnLayout + // Trading Informations + TradingInfo.Main { + id: tradingInfo Layout.alignment: Qt.AlignTop - Layout.minimumWidth: selectors.visible || tradingInfo.visible ? 450 : -1 + Layout.minimumWidth: tradingInfo.visible ? 450 : -1 Layout.maximumWidth: (!orderBook.visible && !bestOrders.visible) || (!placeOrderForm.visible) ? -1 : 450 Layout.fillHeight: true - spacing: 10 - - // Ticker selectors. - TickerSelectors - { - id: selectors - Layout.fillWidth: true - Layout.preferredHeight: 70 - } - - // Trading Informations - TradingInfo.Main - { - id: tradingInfo - Layout.maximumWidth: 450 - Layout.fillHeight: true - } } // Best Orders & Order Book diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml index a102ecb8ce..83ba16e7fe 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml @@ -170,7 +170,6 @@ Item width: parent.width height: parent.height * 0.06 - proViewTickerSelectors: proView.tickerSelectors proViewTrInfo: proView.trInfo proViewMarketsOrderBook: proView.marketsOrderBook proViewPlaceOrderForm: proView.placeOrderForm diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml b/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml index be41d57a74..1488d8a4fc 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml @@ -19,7 +19,6 @@ import "../../../Constants" Item { // property var proViewChart - property var proViewTickerSelectors property var proViewTrInfo property var proViewMarketsOrderBook property var proViewPlaceOrderForm @@ -34,8 +33,8 @@ Item { id: cursorRect width: _simpleLabel.width + 28 - height: _simpleLabel.height + 14 - radius: 16 + height: _simpleLabel.height + 8 + radius: 8 anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: API.app.trading_pg.current_trading_mode == TradingMode.Simple ? _simpleLabel.horizontalCenter : _proLabel.horizontalCenter color: Dex.CurrentTheme.tabSelectedColor @@ -90,11 +89,12 @@ Item outlined: false highlighted: false + padding: 6 foregroundColor: Dex.CurrentTheme.foregroundColor icon.source: Qaterial.Icons.cog text: qsTr("Pro View Settings") - font: DexTypo.subtitle1 + font: DexTypo.subtitle2 onClicked: { @@ -110,22 +110,18 @@ Item contentItem: Item { implicitWidth: 200 - implicitHeight: 240 + implicitHeight: 200 Column { anchors.fill: parent - padding: 10 + padding: 8 spacing: 8 DefaultText { text: qsTr("Display Settings"); font: DexTypo.body2 } HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - CheckEye { text: qsTr("Ticker Selectors"); target: proViewTickerSelectors } - - HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - CheckEye { text: qsTr("Trading Information"); target: proViewTrInfo } HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } From 8e6690ce1026852d1cd63ef020f78046819c0092 Mon Sep 17 00:00:00 2001 From: smk762 Date: Wed, 3 Apr 2024 05:05:45 +0800 Subject: [PATCH 14/26] refactor dex pro --- .../Exchange/ProView/PlaceOrderForm/Main.qml | 232 ++++++------------ .../ProView/PlaceOrderForm/OrderForm.qml | 134 +++++++++- .../Dex/Exchange/Trade/BestOrder/List.qml | 3 +- .../Dex/Exchange/Trade/Market.qml | 4 - .../Dex/Exchange/Trade/OrderBook/Vertical.qml | 6 +- .../Dex/Exchange/Trade/ProView.qml | 4 +- .../Trade/Trading/TradeViewHeader.qml | 4 +- 7 files changed, 218 insertions(+), 169 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml index 0c937d385c..b9435d83b9 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml @@ -11,19 +11,26 @@ import Dex.Components 1.0 as Dex import AtomicDEX.MarketMode 1.0 import AtomicDEX.TradingError 1.0 -Widget +ColumnLayout { - title: qsTr("Place Order") + Layout.preferredWidth: 305 + Layout.fillHeight: true + property alias currentIndex: orderformTabView.currentIndex property int loop_count: 0 property bool show_waiting_for_trade_preimage: false; property var fees: API.app.trading_pg.fees property var preimage_rpc_busy: API.app.trading_pg.preimage_rpc_busy property var trade_preimage_error: fees.hasOwnProperty('error') ? fees["error"].split("] ").slice(-1) : "" readonly property bool trade_preimage_ready: fees.hasOwnProperty('base_transaction_fees_ticker') - readonly property bool can_submit_trade: last_trading_error === TradingError.None - margins: 10 - collapsable: false + function reset_fees_state() + { + show_waiting_for_trade_preimage = false; + check_trade_preimage.stop() + loop_count = 0 + API.app.trading_pg.reset_fees() + formBase.dexErrors.text_value = "" + } Connections { target: API.app.trading_pg @@ -58,155 +65,8 @@ Widget } } - function reset_fees_state() - { - show_waiting_for_trade_preimage = false; - check_trade_preimage.stop() - loop_count = 0 - API.app.trading_pg.reset_fees() - errors.text_value = "" - } - - OrderForm - { - id: formBase - width: parent.width - height: 330 - Layout.alignment: Qt.AlignHCenter - } - - - Item { Layout.fillHeight: true } - - // Error messages - // TODO: Move to toasts - Item - { - height: 55 - Layout.preferredWidth: parent.width - - // Show errors - Dex.Text - { - id: errors - visible: errors.text_value !== "" - anchors.fill: parent - anchors.centerIn: parent - horizontalAlignment: Text.AlignHCenter - font.pixelSize: Style.textSizeSmall4 - color: Dex.CurrentTheme.warningColor - text_value: General.getTradingError( - last_trading_error, - curr_fee_info, - base_ticker, - rel_ticker, left_ticker, right_ticker) - elide: Text.ElideRight - } - } - - Item { Layout.fillHeight: true } - - // Order selected indicator - Item - { - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - 16 - height: 28 - - RowLayout - { - id: orderSelection - visible: API.app.trading_pg.preferred_order.price !== undefined - anchors.fill: parent - anchors.verticalCenter: parent.verticalCenter - - DefaultText - { - Layout.leftMargin: 15 - color: Dex.CurrentTheme.warningColor - text: qsTr("Order Selected") - } - - Item { Layout.fillWidth: true } - - Qaterial.FlatButton - { - Layout.preferredHeight: parent.height - Layout.preferredWidth: 30 - Layout.rightMargin: 5 - foregroundColor: Dex.CurrentTheme.warningColor - onClicked: { - API.app.trading_pg.reset_order() - reset_fees_state() - } - - Qaterial.ColorIcon - { - anchors.centerIn: parent - iconSize: 16 - color: Dex.CurrentTheme.warningColor - source: Qaterial.Icons.close - } - } - } - - Rectangle - { - visible: API.app.trading_pg.preferred_order.price !== undefined - anchors.fill: parent - radius: 8 - color: 'transparent' - border.color: Dex.CurrentTheme.warningColor - } - } - - - TotalView + Timer { - height: 70 - Layout.preferredWidth: parent.width - Layout.alignment: Qt.AlignHCenter - } - - DexGradientAppButton - { - id: swap_btn - height: 32 - Layout.preferredWidth: parent.width - 30 - Layout.alignment: Qt.AlignHCenter - - radius: 16 - text: qsTr("START SWAP") - font.weight: Font.Medium - enabled: can_submit_trade && !show_waiting_for_trade_preimage && errors.text_value == "" - onClicked: - { - console.log("Getting fees info...") - API.app.trading_pg.determine_fees() - show_waiting_for_trade_preimage = true; - check_trade_preimage.start() - } - - Item - { - visible: show_waiting_for_trade_preimage - height: parent.height - 10 - width: parent.width - 10 - anchors.fill: parent - anchors.centerIn: parent - - DefaultBusyIndicator - { - id: preimage_BusyIndicator - anchors.fill: parent - anchors.centerIn: parent - indicatorSize: 32 - indicatorDotSize: 5 - } - } - } - - Timer { id: check_trade_preimage interval: 500; running: false; @@ -225,7 +85,7 @@ Widget else if (trade_preimage_error != "") { loop_count = 0 - errors.text_value = trade_preimage_error.toString() + formBase.dexErrors.text_value = trade_preimage_error.toString() show_waiting_for_trade_preimage = false stop() } @@ -238,4 +98,66 @@ Widget } } } -} + + Qaterial.LatoTabBar + { + id: orderformTabView + property int orderform_idx: 0 + + background: null + Layout.leftMargin: 6 + + Qaterial.LatoTabButton + { + text: qsTr("Place Order") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor + } + } + + Rectangle + { + Layout.fillHeight: true + color: Dex.CurrentTheme.floatingBackgroundColor + radius: 10 + Layout.preferredWidth: 305 + + Qaterial.SwipeView + { + id: orderformSwipeView + clip: true + interactive: false + currentIndex: orderformTabView.currentIndex + anchors.fill: parent + + onCurrentIndexChanged: + { + orderformSwipeView.currentItem.update(); + } + + Item + { + id: orderFormWidget + + OrderForm + { + id: formBase + width: parent.width + height: 330 + Layout.alignment: Qt.AlignHCenter + swap_btn.enabled: last_trading_error === TradingError.None && !show_waiting_for_trade_preimage && formBase.dexErrors.text_value == "" + swap_btn.onClicked: + { + console.log("Getting fees info...") + API.app.trading_pg.determine_fees() + show_waiting_for_trade_preimage = true; + check_trade_preimage.start() + } + swap_btn_spinner.visible: show_waiting_for_trade_preimage + } + } + } + } +} \ No newline at end of file diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml index 3e508ca18c..59a622eabd 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml @@ -2,14 +2,20 @@ import QtQuick 2.15 import QtQuick.Layouts 1.15 import QtQuick.Controls 2.15 import QtGraphicalEffects 1.0 - +import Qaterial 1.0 as Qaterial import "../../../Components" +import "../../../Constants" import App 1.0 import Dex.Themes 1.0 as Dex +import Dex.Components 1.0 as Dex +import AtomicDEX.TradingError 1.0 ColumnLayout { id: root + anchors.horizontalCenter: parent.horizontalCenter + anchors.fill: parent + anchors.margins: 20 spacing: 8 function focusVolumeField() @@ -20,6 +26,9 @@ ColumnLayout readonly property string total_amount: API.app.trading_pg.total_amount readonly property int input_height: 65 readonly property int subfield_margin: 5 + property alias swap_btn: swap_btn + property alias swap_btn_spinner: swap_btn_spinner + property alias dexErrors: dexErrors // Will move to backend: Minimum Fee @@ -263,4 +272,127 @@ ColumnLayout font.pixelSize: 13 } } + + Item { Layout.fillHeight: true } + + // Error messages + // TODO: Move to toasts + Item + { + height: 55 + Layout.preferredWidth: parent.width + + // Show errors + Dex.Text + { + id: dexErrors + visible: dexErrors.text_value !== "" + anchors.fill: parent + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Style.textSizeSmall4 + color: Dex.CurrentTheme.warningColor + text_value: General.getTradingError( + last_trading_error, + curr_fee_info, + base_ticker, + rel_ticker, left_ticker, right_ticker) + elide: Text.ElideRight + } + } + + Item { Layout.fillHeight: true } + + // Order selected indicator + Item + { + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: parent.width - 16 + height: 28 + + RowLayout + { + id: orderSelection + visible: API.app.trading_pg.preferred_order.price !== undefined + anchors.fill: parent + anchors.verticalCenter: parent.verticalCenter + + DefaultText + { + Layout.leftMargin: 15 + color: Dex.CurrentTheme.warningColor + text: qsTr("Order Selected") + } + + Item { Layout.fillWidth: true } + + Qaterial.FlatButton + { + Layout.preferredHeight: parent.height + Layout.preferredWidth: 30 + Layout.rightMargin: 5 + foregroundColor: Dex.CurrentTheme.warningColor + onClicked: { + API.app.trading_pg.reset_order() + reset_fees_state() + } + + Qaterial.ColorIcon + { + anchors.centerIn: parent + iconSize: 16 + color: Dex.CurrentTheme.warningColor + source: Qaterial.Icons.close + } + } + } + + Rectangle + { + visible: API.app.trading_pg.preferred_order.price !== undefined + anchors.fill: parent + radius: 8 + color: 'transparent' + border.color: Dex.CurrentTheme.warningColor + } + } + + + TotalView + { + height: 70 + Layout.preferredWidth: parent.width + Layout.alignment: Qt.AlignHCenter + } + + DexGradientAppButton + { + id: swap_btn + height: 32 + Layout.preferredWidth: parent.width - 30 + Layout.alignment: Qt.AlignHCenter + + radius: 16 + text: qsTr("START SWAP") + font.weight: Font.Medium + + Item + { + id: swap_btn_spinner + height: parent.height - 10 + width: parent.width - 10 + anchors.fill: parent + anchors.centerIn: parent + + DefaultBusyIndicator + { + id: preimage_BusyIndicator + anchors.fill: parent + anchors.centerIn: parent + indicatorSize: 32 + indicatorDotSize: 5 + } + } + } + } \ No newline at end of file diff --git a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml index e179c4c8b6..552ee7bbff 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml @@ -14,7 +14,8 @@ import Dex.Components 1.0 as Dex Widget { id: _control - title: qsTr("Best Orders") + title: qsTr("Best Orders for %1").arg(left_ticker) + margins: 10 spacing: 10 collapsable: false diff --git a/atomic_defi_design/Dex/Exchange/Trade/Market.qml b/atomic_defi_design/Dex/Exchange/Trade/Market.qml index 2940068ecf..3c6af075e6 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Market.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Market.qml @@ -73,16 +73,12 @@ ColumnLayout OrderBook.Vertical { id: orderBook - Layout.fillHeight: true - Layout.fillWidth: true } // Best Orders BestOrder.List { id: bestOrders - Layout.fillHeight: true - Layout.fillWidth: true } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml index 2b0a3bdedf..74d07bcafc 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml @@ -11,13 +11,13 @@ import Dex.Themes 1.0 as Dex Widget { - title: qsTr("Order Book") + title: qsTr("%1 Orderbook").arg(left_ticker + "/" + right_ticker) readonly property string pair_trades_24hr: API.app.trading_pg.pair_trades_24hr readonly property string pair_volume_24hr: API.app.trading_pg.pair_volume_24hr readonly property string pair: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + "/" + atomic_qt_utilities.retrieve_main_ticker(right_ticker) - margins: 8 - spacing: 2 + margins: 10 + spacing: 10 collapsable: false Header diff --git a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml index 877e443b3c..20b051b1c0 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml @@ -113,7 +113,7 @@ RowLayout id: tradingInfo Layout.alignment: Qt.AlignTop Layout.minimumWidth: tradingInfo.visible ? 450 : -1 - Layout.maximumWidth: (!orderBook.visible && !bestOrders.visible) || (!placeOrderForm.visible) ? -1 : 450 + Layout.maximumWidth: (!marketsOrderBook.visible) || (!placeOrderForm.visible) ? -1 : 450 Layout.fillHeight: true } @@ -137,8 +137,6 @@ RowLayout Layout.maximumWidth: 305 Layout.fillWidth: true Layout.fillHeight: true - - resizable: false } ModalLoader diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml b/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml index 1488d8a4fc..f92fc23130 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml @@ -126,11 +126,11 @@ Item HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - CheckEye { text: qsTr("Markets"); target: proViewMarketsOrderBook } + CheckEye { text: qsTr("Order Book"); target: proViewMarketsOrderBook } HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - CheckEye { text: qsTr("Place Order"); target: proViewPlaceOrderForm } + CheckEye { text: qsTr("Order Form"); target: proViewPlaceOrderForm } } } } From 8c2f797f4ee8d22741f9bb7659a3b367e6b20149 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 4 Apr 2024 01:09:15 +0800 Subject: [PATCH 15/26] add checkbox for good until canceled --- .../ProView/PlaceOrderForm/OrderForm.qml | 1 + .../ProView/TradingInfo/PriceLine.qml | 20 +++++++------- .../Dex/Exchange/Trade/ConfirmTradeModal.qml | 27 ++++++++++++++----- .../Exchange/Trade/PriceLineSimplified.qml | 23 +++++++++------- 4 files changed, 43 insertions(+), 28 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml index 59a622eabd..c33cd23958 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml @@ -273,6 +273,7 @@ ColumnLayout } } + Item { Layout.fillHeight: true } // Error messages diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/PriceLine.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/PriceLine.qml index cab141ecff..4eb305bef1 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/PriceLine.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/PriceLine.qml @@ -66,17 +66,6 @@ ColumnLayout visible: price_entered && !invalid_cex_price Layout.alignment: Qt.AlignCenter - DefaultText - { - id: price_diff_text - Layout.topMargin: 10 - Layout.bottomMargin: Layout.topMargin - Layout.alignment: Qt.AlignHCenter - color: parseFloat(cexPriceDiff) <= 0 ? Dex.CurrentTheme.okColor : Dex.CurrentTheme.warningColor - text_value: (parseFloat(cexPriceDiff) > 0 ? qsTr("Expensive") : qsTr("Expedient")) + ":    " + qsTr("%1 compared to CEX", "PRICE_DIFF%").arg("" + General.formatPercent(General.limitDigits(cexPriceDiff)) + "") - font.pixelSize: fontSize - } - RowLayout { Layout.alignment: Qt.AlignHCenter @@ -103,6 +92,15 @@ ColumnLayout } } + DefaultText + { + id: price_diff_text + anchors.horizontalCenter: parent.horizontalCenter + color: parseFloat(cexPriceDiff) <= 0 ? Dex.CurrentTheme.okColor : Dex.CurrentTheme.warningColor + text_value: (parseFloat(cexPriceDiff) > 0 ? qsTr("Expensive") : qsTr("Expedient")) + ":    " + qsTr("%1 compared to CEX", "PRICE_DIFF%").arg("" + General.formatPercent(General.limitDigits(cexPriceDiff)) + "") + font.pixelSize: fontSizeBigger + } + DefaultText { text_value: General.formatPercent(-lineScale) diff --git a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml index 4054ef6606..85670b456d 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml @@ -28,7 +28,7 @@ MultipageModal titleAlignment: Qt.AlignHCenter titleTopMargin: 0 topMarginAfterTitle: 10 - flickMax: window.height - 480 + flickMax: window.height - 500 header: [ RowLayout @@ -43,6 +43,7 @@ MultipageModal PairItemBadge { ticker: base_ticker + is_left: true fullname: General.coinName(base_ticker) amount: base_amount Layout.fillHeight: true @@ -119,6 +120,8 @@ MultipageModal { Layout.alignment: Qt.AlignHCenter text_value: qsTr("This swap request can not be undone and is a final event!") + font: DexTypo.italic12 + color: Dex.CurrentTheme.foregroundColor2 } DefaultText @@ -126,7 +129,8 @@ MultipageModal id: warnings_tx_time_text Layout.alignment: Qt.AlignHCenter text_value: qsTr("This transaction can take up to 60 mins - DO NOT close this application!") - font.pixelSize: Style.textSizeSmall4 + font: DexTypo.italic12 + color: Dex.CurrentTheme.foregroundColor2 } } ] @@ -138,9 +142,9 @@ MultipageModal readonly property var default_config: API.app.trading_pg.get_raw_mm2_coin_cfg(rel_ticker) readonly property bool is_dpow_configurable: config_section.default_config.requires_notarization || false - width: dex_pair_badges.width - 20 + width: dex_pair_badges.width - 40 Layout.alignment: Qt.AlignCenter - Layout.topMargin: 8 + Layout.topMargin: 4 spacing: 5 @@ -239,7 +243,7 @@ MultipageModal } } - // Custom config checkbox + // Custom config section Item { Layout.alignment: Qt.AlignCenter @@ -251,9 +255,18 @@ MultipageModal { id: use_custom anchors.horizontalCenter: parent.horizontalCenter - spacing: 5 + DefaultCheckBox + { + id: _goodUntilCanceledCheckbox + boxWidth: 20 + boxHeight: 20 + checked: true + height: 40 + text: qsTr("Good until canceled (order will remain on orderbook until filled or canceled)") + } + DefaultCheckBox { id: enable_custom_config @@ -261,7 +274,7 @@ MultipageModal spacing: 2 boxWidth: 20 boxHeight: 20 - height: 50 + height: 40 label.wrapMode: Label.NoWrap text: qsTr("Use custom protection settings for incoming %1 transactions", "TICKER").arg(rel_ticker) diff --git a/atomic_defi_design/Dex/Exchange/Trade/PriceLineSimplified.qml b/atomic_defi_design/Dex/Exchange/Trade/PriceLineSimplified.qml index abbc8c8125..4eb4d92c18 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/PriceLineSimplified.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/PriceLineSimplified.qml @@ -22,7 +22,7 @@ ColumnLayout readonly property int fontSizeBigger: Style.textSizeSmall2 readonly property int lineScale: General.getComparisonScale(cexPriceDiff) - spacing: 35 + spacing: 24 RowLayout { @@ -126,10 +126,22 @@ ColumnLayout { text_value: General.formatPercent(lineScale) font.pixelSize: fontSize + anchors.left: parent.left anchors.top: parent.top anchors.topMargin: -15 } + DefaultText + { + id: price_diff_text + anchors.top: parent.top + anchors.topMargin: -15 + anchors.horizontalCenter: parent.horizontalCenter + color: parseFloat(cexPriceDiff) <= 0 ? Dex.CurrentTheme.okColor : Dex.CurrentTheme.warningColor + text_value: (parseFloat(cexPriceDiff) > 0 ? qsTr("Expensive") : qsTr("Expedient")) + ":    " + qsTr("%1 compared to CEX", "PRICE_DIFF%").arg("" + General.formatPercent(General.limitDigits(cexPriceDiff)) + "") + font.pixelSize: fontSizeBigger + } + DefaultText { text_value: General.formatPercent(-lineScale) @@ -141,14 +153,5 @@ ColumnLayout } } - DefaultText - { - id: price_diff_text - Layout.topMargin: 10 - Layout.alignment: Qt.AlignHCenter - color: parseFloat(cexPriceDiff) <= 0 ? Dex.CurrentTheme.okColor : Dex.CurrentTheme.warningColor - text_value: (parseFloat(cexPriceDiff) > 0 ? qsTr("Expensive") : qsTr("Expedient")) + ":    " + qsTr("%1 compared to CEX", "PRICE_DIFF%").arg("" + General.formatPercent(General.limitDigits(cexPriceDiff)) + "") - font.pixelSize: fontSize - } } } From c6d98dfbd3d435fa1aca82d5b4eb120bce33b3a4 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 4 Apr 2024 13:23:05 +0800 Subject: [PATCH 16/26] apply order_type to rpc req body --- .../MarketModeSelector.qml | 0 .../ProView/PlaceOrderForm/OrderForm.qml | 31 +++++++++++++++++ .../Dex/Exchange/ProView/TradingInfo/Main.qml | 34 ------------------- .../Dex/Exchange/Trade/ConfirmTradeModal.qml | 5 +-- .../Trade/SimpleView/OrderRemovedModal.qml | 2 +- .../Dex/Exchange/Trade/Trade.qml | 4 +-- src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.cpp | 5 ++- src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.hpp | 4 ++- .../atomicdex/api/mm2/rpc_v1/rpc.sell.cpp | 1 - src/core/atomicdex/pages/qt.trading.page.cpp | 29 ++++++++++++++-- src/core/atomicdex/pages/qt.trading.page.hpp | 4 +-- 11 files changed, 73 insertions(+), 46 deletions(-) rename atomic_defi_design/Dex/Exchange/ProView/{TradingInfo => PlaceOrderForm}/MarketModeSelector.qml (100%) diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/MarketModeSelector.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml similarity index 100% rename from atomic_defi_design/Dex/Exchange/ProView/TradingInfo/MarketModeSelector.qml rename to atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml index c33cd23958..74f70abbb4 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml @@ -9,6 +9,7 @@ import App 1.0 import Dex.Themes 1.0 as Dex import Dex.Components 1.0 as Dex import AtomicDEX.TradingError 1.0 +import AtomicDEX.MarketMode 1.0 as Dex ColumnLayout { @@ -61,6 +62,36 @@ ColumnLayout function onBackend_volumeChanged() { input_volume.text = exchange_trade.backend_volume; } } + // Market mode selector + RowLayout + { + Layout.topMargin: 2 + Layout.bottomMargin: 2 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: parent.width + height: 28 + + MarketModeSelector + { + Layout.alignment: Qt.AlignLeft + Layout.preferredWidth: 125 + Layout.preferredHeight: 28 + marketMode: Dex.MarketMode.Buy + ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + } + + Item { Layout.fillWidth: true } + + MarketModeSelector + { + marketMode: Dex.MarketMode.Sell + Layout.alignment: Qt.AlignRight + Layout.preferredWidth: 125 + Layout.preferredHeight: 28 + ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + } + } + Item { Layout.preferredWidth: parent.width diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml index a6ab52038d..3246d7b555 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml @@ -86,40 +86,6 @@ ColumnLayout Layout.rightMargin: 8 } - // Market mode selector - RowLayout - { - Layout.topMargin: 2 - Layout.bottomMargin: 2 - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: 435 - height: 28 - - Item { Layout.fillWidth: true } - MarketModeSelector - { - Layout.alignment: Qt.AlignLeft - Layout.preferredWidth: 150 - Layout.preferredHeight: 28 - marketMode: MarketMode.Buy - ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) - } - - Item { Layout.fillWidth: true } - - Item { Layout.fillWidth: true } - - MarketModeSelector - { - Layout.alignment: Qt.AlignRight - Layout.preferredWidth: 150 - Layout.preferredHeight: 28 - ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) - } - Item { Layout.fillWidth: true } - } - - // Chart Chart { diff --git a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml index 85670b456d..b39d54f6c9 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml @@ -264,7 +264,7 @@ MultipageModal boxHeight: 20 checked: true height: 40 - text: qsTr("Good until canceled (order will remain on orderbook until filled or canceled)") + text: qsTr("Good until cancelled (order will remain on orderbook until filled or cancelled)") } DefaultCheckBox @@ -450,7 +450,8 @@ MultipageModal trade({ enable_custom_config: enable_custom_config.checked, is_dpow_configurable: config_section.is_dpow_configurable, enable_dpow_confs: enable_dpow_confs.checked, - required_confirmation_count: required_confirmation_count.value, }, + required_confirmation_count: required_confirmation_count.value, + good_until_canceled: _goodUntilCanceledCheckbox.checked}, config_section.default_config) API.app.trading_pg.reset_fees() } diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/OrderRemovedModal.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/OrderRemovedModal.qml index dc49f96c39..4d5c8fe011 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/OrderRemovedModal.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/OrderRemovedModal.qml @@ -17,7 +17,7 @@ MultipageModal Layout.fillWidth: true wrapMode: Text.WordWrap - text: qsTr("The selected order does not exist anymore, it might have been matched or canceled, and no order with a better price is available.\nPlease select a new order.") + text: qsTr("The selected order does not exist anymore, it might have been matched or cancelled, and no order with a better price is available.\nPlease select a new order.") } footer: diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml index 83ba16e7fe..4bff06849c 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml @@ -144,9 +144,9 @@ Item } if (sell_mode) - API.app.trading_pg.place_sell_order(nota, confs) + API.app.trading_pg.place_sell_order(nota, confs, options.good_until_canceled) else - API.app.trading_pg.place_buy_order(nota, confs) + API.app.trading_pg.place_buy_order(nota, confs, options.good_until_canceled) orderPlaced() } diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.cpp b/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.cpp index 06778770c5..00f1680723 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.cpp +++ b/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.cpp @@ -15,7 +15,6 @@ ******************************************************************************/ //! Deps -#include #include //! Project Headers @@ -75,5 +74,9 @@ namespace atomic_dex::mm2 { SPDLOG_INFO("The order is not picked from orderbook we create it from volume = {}, price = {}", j.at("volume").dump(4), request.price); } + if (request.order_type.has_value()) + { + j["order_type"] = request.order_type.value(); + } } } // namespace atomic_dex::mm2 \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.hpp b/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.hpp index 5e31e108e4..8ad547d304 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.hpp +++ b/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.hpp @@ -21,7 +21,7 @@ #include //! Deps -#include +#include //! Project Header #include @@ -43,7 +43,9 @@ namespace atomic_dex::mm2 bool selected_order_use_input_volume{false}; std::optional base_nota{std::nullopt}; std::optional base_confs{std::nullopt}; + // bool is_max; std::optional min_volume{std::nullopt}; + std::optional order_type; }; void to_json(nlohmann::json& j, const buy_request& request); diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.cpp b/src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.cpp index 6779feb367..4566ea7e48 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.cpp +++ b/src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.cpp @@ -15,7 +15,6 @@ ******************************************************************************/ //! Deps -#include #include //! Project Headers diff --git a/src/core/atomicdex/pages/qt.trading.page.cpp b/src/core/atomicdex/pages/qt.trading.page.cpp index 7499496a68..a042b807f5 100644 --- a/src/core/atomicdex/pages/qt.trading.page.cpp +++ b/src/core/atomicdex/pages/qt.trading.page.cpp @@ -138,7 +138,7 @@ namespace atomic_dex } void - trading_page::place_buy_order(const QString& base_nota, const QString& base_confs) + trading_page::place_buy_order(const QString& base_nota, const QString& base_confs, const QString& good_until_canceled) { this->set_buy_sell_rpc_busy(true); this->set_buy_sell_last_rpc_data(QJsonObject{{}}); @@ -178,6 +178,19 @@ namespace atomic_dex .base_confs = base_confs.isEmpty() ? std::optional{std::nullopt} : base_confs.toUInt(), .min_volume = (rel_min_volume_f <= rel_min_trade) ? std::optional{std::nullopt} : get_min_trade_vol().toStdString()}; + if (good_until_canceled == "true") + { + SPDLOG_DEBUG("Good until cancelled order"); + req.order_type = nlohmann::json::object(); + req.order_type.value()["type"] = "GoodTillCancelled"; + } + else + { + SPDLOG_DEBUG("Fill or kill order"); + req.order_type = nlohmann::json::object(); + req.order_type.value()["type"] = "FillOrKill"; + } + if (is_selected_min_max || is_selected_order) { req.min_volume = std::optional{std::nullopt}; @@ -269,7 +282,7 @@ namespace atomic_dex } void - trading_page::place_sell_order(const QString& rel_nota, const QString& rel_confs) + trading_page::place_sell_order(const QString& rel_nota, const QString& rel_confs, const QString& good_until_canceled) { this->set_buy_sell_rpc_busy(true); this->set_buy_sell_last_rpc_data(QJsonObject{{}}); @@ -312,6 +325,18 @@ namespace atomic_dex req.order_type.value()["type"] = "FillOrKill"; req.min_volume = std::optional{std::nullopt}; } + else if (good_until_canceled == "true") + { + SPDLOG_DEBUG("Good until cancelled order"); + req.order_type = nlohmann::json::object(); + req.order_type.value()["type"] = "GoodTillCancelled"; + } + else + { + SPDLOG_DEBUG("Fill or kill order"); + req.order_type = nlohmann::json::object(); + req.order_type.value()["type"] = "FillOrKill"; + } if (is_selected_min_max) { diff --git a/src/core/atomicdex/pages/qt.trading.page.hpp b/src/core/atomicdex/pages/qt.trading.page.hpp index ccbbf2c3c3..01d8d03138 100644 --- a/src/core/atomicdex/pages/qt.trading.page.hpp +++ b/src/core/atomicdex/pages/qt.trading.page.hpp @@ -161,8 +161,8 @@ namespace atomic_dex Q_INVOKABLE bool set_pair(bool is_left_side, const QString& changed_ticker); Q_INVOKABLE void set_current_orderbook(const QString& base, const QString& rel); ///< market_selector (called and selecting another coin) - Q_INVOKABLE void place_buy_order(const QString& base_nota = "", const QString& base_confs = ""); - Q_INVOKABLE void place_sell_order(const QString& rel_nota = "", const QString& rel_confs = ""); + Q_INVOKABLE void place_buy_order(const QString& base_nota = "", const QString& base_confs = "", const QString& good_until_canceled = ""); + Q_INVOKABLE void place_sell_order(const QString& rel_nota = "", const QString& rel_confs = "", const QString& good_until_canceled = ""); Q_INVOKABLE void reset_order(); From c6148a7933691bfaf1144aaf1dde3bcb1b9c37bf Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 4 Apr 2024 21:14:41 +0800 Subject: [PATCH 17/26] adds maker order tab --- .../Dex/Components/DexGradientAppButton.qml | 1 - .../Exchange/ProView/PlaceOrderForm/Main.qml | 55 ++++++++-- .../ProView/PlaceOrderForm/OrderForm.qml | 40 +++---- .../Dex/Exchange/Trade/ConfirmTradeModal.qml | 20 +++- .../Dex/Exchange/Trade/ProView.qml | 2 +- .../Dex/Exchange/Trade/Trade.qml | 34 ++++-- .../atomicdex/api/mm2/rpc_v1/rpc.setprice.cpp | 6 +- .../atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp | 3 +- src/core/atomicdex/pages/qt.trading.page.cpp | 102 ++++++++++++++++++ src/core/atomicdex/pages/qt.trading.page.hpp | 6 ++ 10 files changed, 220 insertions(+), 49 deletions(-) diff --git a/atomic_defi_design/Dex/Components/DexGradientAppButton.qml b/atomic_defi_design/Dex/Components/DexGradientAppButton.qml index 5624512c13..b4485f7c9a 100644 --- a/atomic_defi_design/Dex/Components/DexGradientAppButton.qml +++ b/atomic_defi_design/Dex/Components/DexGradientAppButton.qml @@ -22,7 +22,6 @@ DexRectangle property bool text_left_align: false - property int minWidth: 90 property real textScale: 1 diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml index b9435d83b9..2874538fcd 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml @@ -22,6 +22,8 @@ ColumnLayout property var preimage_rpc_busy: API.app.trading_pg.preimage_rpc_busy property var trade_preimage_error: fees.hasOwnProperty('error') ? fees["error"].split("] ").slice(-1) : "" readonly property bool trade_preimage_ready: fees.hasOwnProperty('base_transaction_fees_ticker') + property int takerOrderform_idx: 0 + property int makerOrderform_idx: 1 function reset_fees_state() { @@ -29,7 +31,8 @@ ColumnLayout check_trade_preimage.stop() loop_count = 0 API.app.trading_pg.reset_fees() - formBase.dexErrors.text_value = "" + takerForm.dexErrors.text_value = "" + makerForm.dexErrors.text_value = "" } Connections { @@ -85,7 +88,8 @@ ColumnLayout else if (trade_preimage_error != "") { loop_count = 0 - formBase.dexErrors.text_value = trade_preimage_error.toString() + takerForm.dexErrors.text_value = trade_preimage_error.toString() + makerForm.dexErrors.text_value = trade_preimage_error.toString() show_waiting_for_trade_preimage = false stop() } @@ -102,14 +106,21 @@ ColumnLayout Qaterial.LatoTabBar { id: orderformTabView - property int orderform_idx: 0 background: null Layout.leftMargin: 6 Qaterial.LatoTabButton { - text: qsTr("Place Order") + text: qsTr("Taker Order") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor + } + Qaterial.LatoTabButton + { + text: qsTr("Maker Order") font.pixelSize: 14 textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 textSecondaryColor: Dex.CurrentTheme.foregroundColor2 @@ -134,23 +145,51 @@ ColumnLayout onCurrentIndexChanged: { - orderformSwipeView.currentItem.update(); + console.log("onCurrentIndexChanged: " + currentIndex) + API.app.trading_pg.maker_mode = currentIndex === makerOrderform_idx ? true : false + orderformSwipeView.currentItem.update() + console.log("API.app.trading_pg.maker_mode: " + API.app.trading_pg.maker_mode) + } + + Item + { + id: takerOrderform + + OrderForm + { + id: takerForm + width: parent.width + height: 330 + Layout.alignment: Qt.AlignHCenter + swap_btn.enabled: last_trading_error === TradingError.None && !show_waiting_for_trade_preimage && takerForm.dexErrors.text_value == "" + swap_btn.onClicked: + { + console.log("Getting fees info...") + API.app.trading_pg.determine_fees() + show_waiting_for_trade_preimage = true + check_trade_preimage.start() + } + swap_btn_spinner.visible: show_waiting_for_trade_preimage + } } Item { - id: orderFormWidget + id: makerOrderform OrderForm { - id: formBase + id: makerForm width: parent.width height: 330 Layout.alignment: Qt.AlignHCenter - swap_btn.enabled: last_trading_error === TradingError.None && !show_waiting_for_trade_preimage && formBase.dexErrors.text_value == "" + swap_btn.enabled: last_trading_error === TradingError.None && !show_waiting_for_trade_preimage && makerForm.dexErrors.text_value == "" swap_btn.onClicked: { console.log("Getting fees info...") + console.log("API.app.trading_pg.market_mode") + console.log(API.app.trading_pg.market_mode) + // TODO: Apply reduced fees on maker orders API.app.trading_pg.determine_fees() show_waiting_for_trade_preimage = true; check_trade_preimage.start() diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml index 74f70abbb4..1cc7440e66 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml @@ -70,6 +70,7 @@ ColumnLayout Layout.alignment: Qt.AlignHCenter Layout.preferredWidth: parent.width height: 28 + visible: !API.app.trading_pg.maker_mode MarketModeSelector { @@ -397,34 +398,27 @@ ColumnLayout Layout.alignment: Qt.AlignHCenter } - DexGradientAppButton + DefaultBusyIndicator { - id: swap_btn - height: 32 - Layout.preferredWidth: parent.width - 30 + id: swap_btn_spinner Layout.alignment: Qt.AlignHCenter - - radius: 16 - text: qsTr("START SWAP") - font.weight: Font.Medium - + indicatorSize: 28 + indicatorDotSize: 4 + } Item + { + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: parent.width - 16 + height: 28 + + DexGradientAppButton { - id: swap_btn_spinner - height: parent.height - 10 - width: parent.width - 10 + id: swap_btn + height: 32 anchors.fill: parent - anchors.centerIn: parent - - DefaultBusyIndicator - { - id: preimage_BusyIndicator - anchors.fill: parent - anchors.centerIn: parent - indicatorSize: 32 - indicatorDotSize: 5 - } + radius: 16 + text: API.app.trading_pg.maker_mode ? qsTr("CREATE MAKER SWAP") : qsTr("START TAKER SWAP") + font.weight: Font.Medium } } - } \ No newline at end of file diff --git a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml index b39d54f6c9..00025081f3 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml @@ -17,8 +17,9 @@ MultipageModal id: root readonly property var fees: API.app.trading_pg.fees width: 720 - horizontalPadding: 20 - verticalPadding: 20 + height: window.height - 80 + horizontalPadding: 10 + verticalPadding: 10 closePolicy: Popup.NoAutoClose MultipageModalContent @@ -28,7 +29,7 @@ MultipageModal titleAlignment: Qt.AlignHCenter titleTopMargin: 0 topMarginAfterTitle: 10 - flickMax: window.height - 500 + flickMax: window.height - 430 header: [ RowLayout @@ -257,9 +258,21 @@ MultipageModal anchors.horizontalCenter: parent.horizontalCenter spacing: 5 + DefaultCheckBox + { + id: _cancelPreviousCheckbox + visible: API.app.trading_pg.maker_mode + boxWidth: 20 + boxHeight: 20 + checked: true + height: 40 + text: qsTr("Cancel all existing orders for %1/%2?").arg(base_ticker).arg(rel_ticker) + } + DefaultCheckBox { id: _goodUntilCanceledCheckbox + visible: !API.app.trading_pg.maker_mode boxWidth: 20 boxHeight: 20 checked: true @@ -451,6 +464,7 @@ MultipageModal is_dpow_configurable: config_section.is_dpow_configurable, enable_dpow_confs: enable_dpow_confs.checked, required_confirmation_count: required_confirmation_count.value, + cancel_previous: _cancelPreviousCheckbox.checked, good_until_canceled: _goodUntilCanceledCheckbox.checked}, config_section.default_config) API.app.trading_pg.reset_fees() diff --git a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml index 20b051b1c0..6ebe7a1f6b 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml @@ -142,6 +142,6 @@ RowLayout ModalLoader { id: confirm_trade_modal - sourceComponent: ConfirmTradeModal {} + sourceComponent: ConfirmTradeModal { } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml index 4bff06849c..aba6f1c6ba 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml @@ -48,27 +48,32 @@ Item readonly property bool price_is_empty: parseFloat(non_null_price) <= 0 readonly property string backend_price: API.app.trading_pg.price + readonly property int last_trading_error: API.app.trading_pg.last_trading_error + readonly property string max_volume: API.app.trading_pg.max_volume + readonly property string backend_volume: API.app.trading_pg.volume + property bool sell_mode: API.app.trading_pg.market_mode.toString() === "Sell" + readonly property string base_amount: API.app.trading_pg.base_amount + readonly property string rel_amount: API.app.trading_pg.rel_amount + function setPrice(v) { API.app.trading_pg.price = v API.app.trading_pg.determine_error_cases() } - readonly property int last_trading_error: API.app.trading_pg.last_trading_error - readonly property string max_volume: API.app.trading_pg.max_volume - readonly property string backend_volume: API.app.trading_pg.volume + function setVolume(v) { API.app.trading_pg.volume = v API.app.trading_pg.determine_error_cases() } + + function setMakerMode(v) { + API.app.trading_pg.maker_mode = v + } - property bool sell_mode: API.app.trading_pg.market_mode.toString( - ) === "Sell" function setMarketMode(v) { API.app.trading_pg.market_mode = v } - readonly property string base_amount: API.app.trading_pg.base_amount - readonly property string rel_amount: API.app.trading_pg.rel_amount - + Timer { id: swap_cooldown @@ -144,9 +149,20 @@ Item } if (sell_mode) - API.app.trading_pg.place_sell_order(nota, confs, options.good_until_canceled) + { + if (API.app.trading_pg.maker_mode) + { + API.app.trading_pg.place_setprice_order(nota, confs, options.cancel_previous) + } + else + { + API.app.trading_pg.place_sell_order(nota, confs, options.good_until_canceled) + } + } else + { API.app.trading_pg.place_buy_order(nota, confs, options.good_until_canceled) + } orderPlaced() } diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.cpp b/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.cpp index a9d0816d74..6977cefa90 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.cpp +++ b/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.cpp @@ -28,8 +28,10 @@ namespace atomic_dex::mm2 j["price"] = request.price; j["rel"] = request.rel; j["volume"] = request.volume; - j["cancel_previous"] = request.cancel_previous; - j["max"] = request.max; + if (request.cancel_previous.has_value()) + { + j["cancel_previous"] = request.cancel_previous.value(); + } if (request.base_nota.has_value()) { j["base_nota"] = request.base_nota.value(); diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp b/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp index 8eb234e274..f169a0002d 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp +++ b/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp @@ -31,8 +31,7 @@ namespace atomic_dex::mm2 std::string rel; std::string price; std::string volume; - bool max{false}; - bool cancel_previous{false}; + std::optional cancel_previous{false}; std::optional base_nota; std::optional base_confs; std::optional rel_nota; diff --git a/src/core/atomicdex/pages/qt.trading.page.cpp b/src/core/atomicdex/pages/qt.trading.page.cpp index a042b807f5..4ee89c213f 100644 --- a/src/core/atomicdex/pages/qt.trading.page.cpp +++ b/src/core/atomicdex/pages/qt.trading.page.cpp @@ -21,6 +21,7 @@ //! Project Headers #include "atomicdex/api/mm2/rpc_v1/rpc.buy.hpp" #include "atomicdex/api/mm2/rpc_v1/rpc.sell.hpp" +#include "atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp" #include "atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp" #include "atomicdex/pages/qt.portfolio.page.hpp" #include "atomicdex/pages/qt.settings.page.hpp" @@ -137,6 +138,90 @@ namespace atomic_dex dispatcher_.trigger(); } + void + trading_page::place_setprice_order(const QString& base_nota, const QString& base_confs, const QString& cancel_previous) + { + this->set_buy_sell_rpc_busy(true); + this->set_buy_sell_last_rpc_data(QJsonObject{{}}); + + auto& mm2_system = m_system_manager.get_system(); + const auto* market_selector = get_market_pairs_mdl(); + const auto& base = market_selector->get_left_selected_coin(); + const auto& rel = market_selector->get_right_selected_coin(); + t_float_50 rel_min_trade = safe_float(get_orderbook_wrapper()->get_rel_min_taker_vol().toStdString()); + t_float_50 rel_min_volume_f = safe_float(get_min_trade_vol().toStdString()); + + t_setprice_request req{ + .base = base.toStdString(), + .rel = rel.toStdString(), + .price = m_price.toStdString(), + .volume = m_volume.toStdString(), + .cancel_previous = cancel_previous == "true", + .base_nota = base_nota.isEmpty() ? std::optional{std::nullopt} : boost::lexical_cast(base_nota.toStdString()), + .base_confs = base_confs.isEmpty() ? std::optional{std::nullopt} : base_confs.toUInt(), + .min_volume = (rel_min_volume_f <= rel_min_trade) ? std::optional{std::nullopt} : get_min_trade_vol().toStdString() + }; + + nlohmann::json batch; + nlohmann::json setprice_request = mm2::template_request("setprice"); + mm2::to_json(setprice_request, req); + batch.push_back(setprice_request); + setprice_request["userpass"] = "*******"; + + //! Answer + SPDLOG_DEBUG("setprice_request is : {}", setprice_request.dump(4)); + auto answer_functor = [this](const web::http::http_response& resp) + { + std::string body = TO_STD_STR(resp.extract_string(true).get()); + if (resp.status_code() == web::http::status_codes::OK) + { + if (body.find("error") == std::string::npos) + { + auto answers = nlohmann::json::parse(body); + nlohmann::json answer = answers[0]; + this->set_buy_sell_last_rpc_data(nlohmann_json_object_to_qt_json_object(answer)); + auto& cur_mm2_system = m_system_manager.get_system(); + SPDLOG_DEBUG("order successfully placed, refreshing orders and swap"); + cur_mm2_system.batch_fetch_orders_and_swap(); + } + else + { + auto error_json = QJsonObject({{"error_code", -1}, {"error_message", QString::fromStdString(body)}}); + SPDLOG_ERROR("error place_setprice_order: {}", body); + this->set_buy_sell_last_rpc_data(error_json); + } + } + else + { + auto error_json = QJsonObject({{"error_code", resp.status_code()}, {"error_message", QString::fromStdString(body)}}); + this->set_buy_sell_last_rpc_data(error_json); + } + this->set_buy_sell_rpc_busy(false); + this->clear_forms("place_setprice_order"); + }; + + //! Async call + mm2_system.get_mm2_client() + .async_rpc_batch_standalone(batch) + .then(answer_functor) + .then( + [this]([[maybe_unused]] pplx::task previous_task) + { + try + { + previous_task.wait(); + } + catch (const std::exception& e) + { + SPDLOG_ERROR("pplx task error: {}", e.what()); + auto error_json = QJsonObject({{"error_code", web::http::status_codes::InternalError}, {"error_message", e.what()}}); + this->set_buy_sell_last_rpc_data(error_json); + this->set_buy_sell_rpc_busy(false); + this->clear_forms("place_setprice_order"); + } + }); + } + void trading_page::place_buy_order(const QString& base_nota, const QString& base_confs, const QString& good_until_canceled) { @@ -627,6 +712,23 @@ namespace atomic_dex //! Properties related to trading namespace atomic_dex { + bool + trading_page::get_maker_mode() const + { + return m_maker_mode; + } + + void + trading_page::set_maker_mode(bool market_mode) + { + if (this->m_maker_mode != market_mode) + { + this->m_maker_mode = market_mode; + emit makerModeChanged(); + this->set_market_mode(MarketMode::Sell); + } + } + MarketMode trading_page::get_market_mode() const { diff --git a/src/core/atomicdex/pages/qt.trading.page.hpp b/src/core/atomicdex/pages/qt.trading.page.hpp index 01d8d03138..4aaa14dedf 100644 --- a/src/core/atomicdex/pages/qt.trading.page.hpp +++ b/src/core/atomicdex/pages/qt.trading.page.hpp @@ -46,6 +46,7 @@ namespace atomic_dex // Trading logic Q properties Q_PROPERTY(MarketMode market_mode READ get_market_mode WRITE set_market_mode NOTIFY marketModeChanged) + Q_PROPERTY(bool maker_mode READ get_maker_mode WRITE set_maker_mode NOTIFY makerModeChanged) Q_PROPERTY(TradingError last_trading_error READ get_trading_error WRITE set_trading_error NOTIFY tradingErrorChanged) Q_PROPERTY(TradingMode current_trading_mode READ get_current_trading_mode WRITE set_current_trading_mode NOTIFY tradingModeChanged) Q_PROPERTY(QString price READ get_price WRITE set_price NOTIFY priceChanged) @@ -107,6 +108,7 @@ namespace atomic_dex //! Trading Logic MarketMode m_market_mode{MarketModeGadget::Sell}; + bool m_maker_mode{false}; TradingError m_last_trading_error{TradingErrorGadget::None}; TradingMode m_current_trading_mode{TradingModeGadget::Pro}; SelectedOrderStatus m_selected_order_status{SelectedOrderGadget::None}; @@ -163,6 +165,7 @@ namespace atomic_dex Q_INVOKABLE void place_buy_order(const QString& base_nota = "", const QString& base_confs = "", const QString& good_until_canceled = ""); Q_INVOKABLE void place_sell_order(const QString& rel_nota = "", const QString& rel_confs = "", const QString& good_until_canceled = ""); + Q_INVOKABLE void place_setprice_order(const QString& rel_nota = "", const QString& rel_confs = "", const QString& cancel_previous = ""); Q_INVOKABLE void reset_order(); @@ -178,6 +181,8 @@ namespace atomic_dex void set_buy_sell_rpc_busy(bool status); //! Trading Logic + [[nodiscard]] bool get_maker_mode() const; + void set_maker_mode(bool market_mode); [[nodiscard]] MarketMode get_market_mode() const; void set_market_mode(MarketMode market_mode); [[nodiscard]] TradingError get_trading_error() const; @@ -232,6 +237,7 @@ namespace atomic_dex //! Trading logic void priceChanged(); void volumeChanged(); + void makerModeChanged(); void marketModeChanged(); void maxVolumeChanged(); void tradingErrorChanged(); From 5e7cf3306e6acd36253a79b529477c307662bd98 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 4 Apr 2024 21:22:11 +0800 Subject: [PATCH 18/26] reset selected trade on tab switch --- .../Dex/Exchange/ProView/PlaceOrderForm/Main.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml index 2874538fcd..f89056a9eb 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml @@ -145,10 +145,10 @@ ColumnLayout onCurrentIndexChanged: { - console.log("onCurrentIndexChanged: " + currentIndex) API.app.trading_pg.maker_mode = currentIndex === makerOrderform_idx ? true : false orderformSwipeView.currentItem.update() - console.log("API.app.trading_pg.maker_mode: " + API.app.trading_pg.maker_mode) + API.app.trading_pg.reset_order() + reset_fees_state() } Item From e5f4fbb9b1b41e91ece9af75627e4ae5ea80132b Mon Sep 17 00:00:00 2001 From: smk762 Date: Fri, 5 Apr 2024 00:15:07 +0800 Subject: [PATCH 19/26] disable orderbook in maker mode --- .../Dex/Exchange/Trade/BestOrder/ListDelegate.qml | 15 +++++++++++---- .../Dex/Exchange/Trade/OrderBook/List.qml | 1 + .../Dex/Exchange/Trade/OrderBook/ListDelegate.qml | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml index e5893f2e31..5da6b0458a 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml @@ -170,15 +170,22 @@ Item else { placeOrderForm.visible = General.flipFalse(placeOrderForm.visible) - if (API.app.trading_pg.market_mode == MarketMode.Buy) + if (!API.app.trading_pg.maker_mode) { - app.pairChanged(coin, rel_ticker) + if (API.app.trading_pg.market_mode == MarketMode.Buy) + { + app.pairChanged(coin, rel_ticker) + } + else + { + app.pairChanged(base_ticker, coin) + } + API.app.trading_pg.orderbook.select_best_order(uuid) } else { - app.pairChanged(base_ticker, coin) + setPair(false, coin) } - API.app.trading_pg.orderbook.select_best_order(uuid) } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml index 23e54d6606..16b15f0d9d 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml @@ -25,6 +25,7 @@ Item clip: true reuseItems: true spacing: 8 + opacity: API.app.trading_pg.maker_mode ? 0.6 : 1 onContentHeightChanged: { diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml index 5ce557fc6b..d9b574f206 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml @@ -44,6 +44,10 @@ Item { if (mouse_area.containsMouse) { + if (API.app.trading_pg.maker_mode) + { + return qsTr("Orderbook is disabled while creating maker orders") + } let relMaxTakerVol = parseFloat(API.app.trading_pg.orderbook.rel_max_taker_vol.decimal); let baseMaxTakerVol = parseFloat(API.app.trading_pg.orderbook.base_max_taker_vol.decimal); @@ -104,6 +108,7 @@ Item onClicked: { if (is_mine) return + if (API.app.trading_pg.maker_mode) return if (enough_funds_to_pay_min_volume ) { From 624b9c7d2c3706b9cad8c9b99ccfd59a26b2abb3 Mon Sep 17 00:00:00 2001 From: smk762 Date: Fri, 5 Apr 2024 15:45:44 +0800 Subject: [PATCH 20/26] rm gitlab ci --- .gitlab-ci.yml | 112 ------------------------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 1c25541055..0000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,112 +0,0 @@ -image: smk762/qt-ci:latest - -stages: - - build - - upload_linux_zip - - upload_linux_tar - - upload_linux_appimage - - test - -variables: - GIT_SUBMODULE_STRATEGY: recursive - DOCKER_DRIVER: overlay2 - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - VCPKG_DEFAULT_BINARY_CACHE: "$CI_PROJECT_DIR/.cache/vcpkg" - QT_VERSION: "5.15.2" - CMAKE_VERSION: "3.20.5" - -cache: - - key: $CI_COMMIT_REF_SLUG - paths: - - komodo-wallet-linux-${CI_COMMIT_SHA::9}.zip - - komodo-wallet-linux-${CI_COMMIT_SHA::9}.tar.zst - - komodo-wallet-${CI_COMMIT_SHA::9}-x86_64.AppImage - - key: $CI_PROJECT_NAME - paths: - - "$CI_PROJECT_DIR/.cache/vcpkg" - - -linux:build: - stage: build - before_script: - - cd $CI_PROJECT_DIR - - mkdir -p .cache/pip - - mkdir -p .cache/vcpkg - - script: - # Job Variables - - echo $CI_COMMIT_REF_SLUG - - echo $CI_COMMIT_AUTHOR - - echo $CI_COMMIT_BRANCH - - echo $CI_COMMIT_SHA - - echo $CI_COMMIT_SHORT_SHA - - echo $CI_PROJECT_PATH - - echo $CI_PROJECT_NAME - - echo $QT_VERSION - - echo $CMAKE_VERSION - - # Job Path/Env variables - - export DEBIAN_FRONTEND=noninteractive - - export QT_INSTALL_CMAKE_PATH=/opt/Qt/$QT_VERSION/gcc_64/lib/cmake - - export QT_ROOT=/opt/Qt/$QT_VERSION - - export Qt5_DIR=/opt/Qt/$QT_VERSION/gcc_64/lib/cmake/Qt5 - - export PATH=/opt/Qt/$QT_VERSION/gcc_64/bin:$PATH - - export PATH=${PATH}:/cmake-$CMAKE_VERSION-linux-x86_64/bin; - - export APPIMAGE_EXTRACT_AND_RUN=1 - - # Update tar - - export FORCE_UNSAFE_CONFIGURE=1 - - wget https://ftp.wayne.edu/gnu/tar/tar-1.34.tar.gz && tar -xvf tar-1.34.tar.gz - - cd tar-1.34 && ./configure && make && make install - - cp src/tar $(which tar) - - # Bootstrap Vcpkg - - cd $CI_PROJECT_DIR; ./ci_tools_atomic_dex/vcpkg-repo/bootstrap-vcpkg.sh - - # NINJA - - cd $CI_PROJECT_DIR - - rm -rf build_ninja || echo "no build_ninja folder to rm" - - mkdir build_ninja && cd $_ - - cmake -DCMAKE_BUILD_TYPE=Release -GNinja ../ - - ninja install - - ninja komodo-wallet - - cd $CI_PROJECT_DIR - - cp $CI_PROJECT_DIR/bundled/linux/komodo-wallet-linux-${CI_COMMIT_SHA::9}.zip . - - cp $CI_PROJECT_DIR/bundled/linux/komodo-wallet-linux-${CI_COMMIT_SHA::9}.tar.zst . - - cp $CI_PROJECT_DIR/bundled/linux/komodo-wallet-${CI_COMMIT_SHA::9}-x86_64.AppImage . - -AtomicDex-linux-zip: - stage: upload_linux_zip - allow_failure: true - script: - - echo "Uploading AppImage..." - artifacts: - name: "AtomicDex-linux-${CI_COMMIT_SHA::9}.zip" - paths: - - $CI_PROJECT_DIR/komodo-wallet-linux-${CI_COMMIT_SHA::9}.zip - when: always - expire_in: 3 days - -AtomicDex-linux-AppImage: - stage: upload_linux_appimage - allow_failure: true - script: - - echo "Uploading AppImage..." - artifacts: - name: "AtomicDex-linux-${CI_COMMIT_SHA::9}-AppImage" - paths: - - $CI_PROJECT_DIR/komodo-wallet-${CI_COMMIT_SHA::9}-x86_64.AppImage - when: always - expire_in: 3 days - -AtomicDex-linux-tar: - stage: upload_linux_tar - allow_failure: true - script: - - echo "Uploading tar..." - artifacts: - name: "AtomicDex-linux-${CI_COMMIT_SHA::9}.tar.zst" - paths: - - $CI_PROJECT_DIR/komodo-wallet-linux-${CI_COMMIT_SHA::9}.tar.zst - when: always - expire_in: 3 days From d2fe9440c8370f158bf21f13b169c6d9bd53d813 Mon Sep 17 00:00:00 2001 From: smk762 Date: Fri, 5 Apr 2024 15:48:09 +0800 Subject: [PATCH 21/26] tweak ci workflows --- .github/workflows/atomicdex-desktop-ci.yml | 1 + .github/workflows/sync_mirror.yml | 26 ---------------------- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 .github/workflows/sync_mirror.yml diff --git a/.github/workflows/atomicdex-desktop-ci.yml b/.github/workflows/atomicdex-desktop-ci.yml index 8cdaa94d95..5891f093e6 100644 --- a/.github/workflows/atomicdex-desktop-ci.yml +++ b/.github/workflows/atomicdex-desktop-ci.yml @@ -8,6 +8,7 @@ on: - master schedule: - cron: '0 0 * * 1' + workflow_dispatch: env: DEX_API: "mm2_kmd" diff --git a/.github/workflows/sync_mirror.yml b/.github/workflows/sync_mirror.yml deleted file mode 100644 index 57010e03dd..0000000000 --- a/.github/workflows/sync_mirror.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: GitlabSync - -on: - push: - branches: - - 'none' - pull_request: - branches: - - none - delete: - branches: - - '*' - -jobs: - sync: - runs-on: ubuntu-latest - name: Git Repo Sync - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: wangchucheng/git-repo-sync@v0.1.0 - with: - target-url: ${{ secrets.GITLAB_URL }} - target-username: ${{ secrets.GITLAB_USERNAME }} - target-token: ${{ secrets.GITLAB_TOKEN }} From 229203afc3d90d118041cb05219c70684192dc40 Mon Sep 17 00:00:00 2001 From: smk762 Date: Sat, 6 Apr 2024 13:49:49 +0800 Subject: [PATCH 22/26] add `is_vote_coin` category --- src/core/atomicdex/config/coins.cfg.cpp | 6 ++++++ src/core/atomicdex/config/coins.cfg.hpp | 2 ++ src/core/atomicdex/constants/dex.constants.hpp | 8 ++++++++ src/core/atomicdex/models/qt.orderbook.model.hpp | 12 ++++++------ src/core/atomicdex/pages/qt.wallet.page.cpp | 2 ++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/core/atomicdex/config/coins.cfg.cpp b/src/core/atomicdex/config/coins.cfg.cpp index 1f846b5376..5b210de4b3 100644 --- a/src/core/atomicdex/config/coins.cfg.cpp +++ b/src/core/atomicdex/config/coins.cfg.cpp @@ -149,6 +149,11 @@ namespace atomic_dex { return std::any_of(g_faucet_coins.begin(), g_faucet_coins.end(), [ticker](std::string x) { return ticker == x; }); } + bool + is_vote_coin(std::string ticker) + { + return std::any_of(g_vote_coins.begin(), g_vote_coins.end(), [ticker](std::string x) { return ticker == x; }); + } void from_json(const nlohmann::json& j, coin_config_t& cfg) @@ -172,6 +177,7 @@ namespace atomic_dex cfg.wallet_only = is_wallet_only(cfg.ticker) ? is_wallet_only(cfg.ticker) : j.contains("wallet_only") ? j.at("wallet_only").get() : false; cfg.default_coin = is_default_coin(cfg.ticker); cfg.is_faucet_coin = is_faucet_coin(cfg.ticker); + cfg.is_vote_coin = is_vote_coin(cfg.ticker); cfg.checkpoint_height = 0; cfg.checkpoint_blocktime = 0; using namespace std::chrono; diff --git a/src/core/atomicdex/config/coins.cfg.hpp b/src/core/atomicdex/config/coins.cfg.hpp index 457b432e8e..7fb2927ddb 100644 --- a/src/core/atomicdex/config/coins.cfg.hpp +++ b/src/core/atomicdex/config/coins.cfg.hpp @@ -67,6 +67,7 @@ namespace atomic_dex bool has_memos{false}; bool is_custom_coin{false}; bool is_faucet_coin{false}; + bool is_vote_coin{false}; bool currently_enabled{false}; bool has_parent_fees_ticker{false}; ///< True if parent fees is different from current ticker eg: ERC20 tokens bool is_erc_family{false}; @@ -102,5 +103,6 @@ namespace atomic_dex bool is_wallet_only(std::string ticker); bool is_default_coin(std::string ticker); bool is_faucet_coin(std::string ticker); + bool is_vote_coin(std::string ticker); } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/constants/dex.constants.hpp b/src/core/atomicdex/constants/dex.constants.hpp index 350793b461..4e12defcb1 100644 --- a/src/core/atomicdex/constants/dex.constants.hpp +++ b/src/core/atomicdex/constants/dex.constants.hpp @@ -17,7 +17,15 @@ namespace atomic_dex "DOC", "MARTY", "ZOMBIE", + "IRISTEST", }; + inline const std::vector g_vote_coins{ + "KIP0002", + "KIP0003", + "KIP0004", + "VOTE2024", + }; + inline const std::vector g_wallet_only_coins{ "ARRR-BEP20", "RBTC", diff --git a/src/core/atomicdex/models/qt.orderbook.model.hpp b/src/core/atomicdex/models/qt.orderbook.model.hpp index 2ec3b7ef84..debd89eba3 100644 --- a/src/core/atomicdex/models/qt.orderbook.model.hpp +++ b/src/core/atomicdex/models/qt.orderbook.model.hpp @@ -53,30 +53,30 @@ namespace atomic_dex PriceRole = Qt::UserRole + 1, // 257 CoinRole, TotalRole, - UUIDRole, + UUIDRole, // 260 IsMineRole, PriceDenomRole, PriceNumerRole, PercentDepthRole, - MinVolumeRole, + MinVolumeRole, // 265 EnoughFundsToPayMinVolume, CEXRatesRole, SendRole, PriceFiatRole, - HaveCEXIDRole, + HaveCEXIDRole, // 270 BaseMinVolumeRole, BaseMinVolumeDenomRole, BaseMinVolumeNumerRole, BaseMaxVolumeRole, - BaseMaxVolumeDenomRole, + BaseMaxVolumeDenomRole, // 275 BaseMaxVolumeNumerRole, RelMinVolumeRole, RelMinVolumeDenomRole, RelMinVolumeNumerRole, - RelMaxVolumeRole, + RelMaxVolumeRole, // 280 RelMaxVolumeDenomRole, RelMaxVolumeNumerRole, - NameAndTicker + NameAndTicker // 283 }; orderbook_model(kind orderbook_kind, ag::ecs::system_manager& system_mgr, QObject* parent = nullptr); diff --git a/src/core/atomicdex/pages/qt.wallet.page.cpp b/src/core/atomicdex/pages/qt.wallet.page.cpp index 7613bc8dc2..14b383dae8 100644 --- a/src/core/atomicdex/pages/qt.wallet.page.cpp +++ b/src/core/atomicdex/pages/qt.wallet.page.cpp @@ -269,6 +269,7 @@ namespace atomic_dex {"transactions_left", 0}, {"current_block", 1}, {"is_faucet_coin", false}, + {"is_vote_coin", false}, {"qrcode_address", ""}, {"segwit_supported", false}}; std::error_code ec; @@ -303,6 +304,7 @@ namespace atomic_dex obj["transactions_left"] = static_cast(tx_state.transactions_left); obj["current_block"] = static_cast(tx_state.current_block); obj["is_faucet_coin"] = coin_info.is_faucet_coin; + obj["is_vote_coin"] = coin_info.is_vote_coin; std::error_code ec; if (!mm2_system.is_zhtlc_coin_ready(coin_info.ticker)) From c86019be2a0483ca35d05325f316cc53a86dbad2 Mon Sep 17 00:00:00 2001 From: smk762 Date: Sat, 6 Apr 2024 13:50:06 +0800 Subject: [PATCH 23/26] add button for vote info in wallet --- atomic_defi_design/Dex/Constants/General.qml | 5 +++ atomic_defi_design/Dex/Wallet/Main.qml | 44 ++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/atomic_defi_design/Dex/Constants/General.qml b/atomic_defi_design/Dex/Constants/General.qml index d57eeb99de..6defe9de94 100644 --- a/atomic_defi_design/Dex/Constants/General.qml +++ b/atomic_defi_design/Dex/Constants/General.qml @@ -88,6 +88,11 @@ QtObject { return API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).is_faucet_coin } + function isVoteCoin(ticker) + { + return API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).is_vote_coin + } + function isCoinWithMemo(ticker) { return API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).has_memos diff --git a/atomic_defi_design/Dex/Wallet/Main.qml b/atomic_defi_design/Dex/Wallet/Main.qml index 3b77efd959..0257a8f57c 100644 --- a/atomic_defi_design/Dex/Wallet/Main.qml +++ b/atomic_defi_design/Dex/Wallet/Main.qml @@ -657,6 +657,50 @@ Item } } + // Proposals Button + Item + { + Layout.preferredWidth: 165 + Layout.preferredHeight: 40 + visible: current_ticker_infos.is_vote_coin + + DefaultButton + { + enabled: activation_pct == 100 + anchors.fill: parent + radius: 18 + label.text: qsTr("Vote Info") + label.font.pixelSize: 16 + content.anchors.left: content.parent.left + content.anchors.leftMargin: enabled ? 23 : 48 + content.anchors.rightMargin: 23 + + onClicked: Qt.openUrlExternally("https://vote.komodoplatform.com/") + + Row + { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 23 + + Qaterial.Icon + { + icon: Qaterial.Icons.vote + size: 24 + anchors.verticalCenter: parent.verticalCenter + color: "#283547" + } + } + } + + // Faucet button error icon + DefaultAlertIcon + { + visible: activation_pct != 100 + tooltipText: api_wallet_page.ticker + qsTr(" Activation: " + activation_pct + "%") + } + } + Component.onCompleted: api_wallet_page.claimingFaucetRpcDataChanged.connect(onClaimFaucetRpcResultChanged) Component.onDestruction: api_wallet_page.claimingFaucetRpcDataChanged.disconnect(onClaimFaucetRpcResultChanged) function onClaimFaucetRpcResultChanged() { claimFaucetResultModal.open() } From d5c73585b28a343265d6ff3ed4a4d3658a955506 Mon Sep 17 00:00:00 2001 From: smk762 Date: Sat, 6 Apr 2024 14:00:12 +0800 Subject: [PATCH 24/26] set vote coins to wallet only --- atomic_defi_design/Dex/Wallet/Main.qml | 2 +- src/core/atomicdex/constants/dex.constants.hpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/atomic_defi_design/Dex/Wallet/Main.qml b/atomic_defi_design/Dex/Wallet/Main.qml index 0257a8f57c..a6dd531cd7 100644 --- a/atomic_defi_design/Dex/Wallet/Main.qml +++ b/atomic_defi_design/Dex/Wallet/Main.qml @@ -688,7 +688,7 @@ Item icon: Qaterial.Icons.vote size: 24 anchors.verticalCenter: parent.verticalCenter - color: "#283547" + color: "#2c87b9" } } } diff --git a/src/core/atomicdex/constants/dex.constants.hpp b/src/core/atomicdex/constants/dex.constants.hpp index 4e12defcb1..7cda6d1817 100644 --- a/src/core/atomicdex/constants/dex.constants.hpp +++ b/src/core/atomicdex/constants/dex.constants.hpp @@ -33,7 +33,10 @@ namespace atomic_dex "PAXG-ERC20", "USDT-ERC20", "XPM", - "VOTE2023", + "KIP0002", + "KIP0003", + "KIP0004", + "VOTE2024", "ATOM" }; } From 98dde1bbc62d5d5713f9225f11a0eb18751e5981 Mon Sep 17 00:00:00 2001 From: smk762 Date: Sat, 6 Apr 2024 16:11:44 +0800 Subject: [PATCH 25/26] move warning to avoid overflow --- .../Dex/Exchange/Trade/ConfirmTradeModal.qml | 115 +++++++++--------- .../pages/widgets/dex/qt.orderbook.cpp | 6 +- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml index 00025081f3..8056ecbef9 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml @@ -29,7 +29,7 @@ MultipageModal titleAlignment: Qt.AlignHCenter titleTopMargin: 0 topMarginAfterTitle: 10 - flickMax: window.height - 430 + flickMax: window.height - 385 header: [ RowLayout @@ -77,62 +77,6 @@ MultipageModal { id: price_line Layout.fillWidth: true - }, - - ColumnLayout - { - id: warnings_text - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter - - // Large margin warning - FloatingBackground - { - Layout.alignment: Qt.AlignCenter - width: childrenRect.width - height: childrenRect.height - color: Style.colorRed2 - visible: Math.abs(parseFloat(API.app.trading_pg.cex_price_diff)) >= 50 - - RowLayout - { - Layout.fillWidth: true - - Item { width: 3 } - - DefaultCheckBox - { - id: allow_bad_trade - Layout.alignment: Qt.AlignCenter - textColor: Style.colorWhite0 - visible: Math.abs(parseFloat(API.app.trading_pg.cex_price_diff)) >= 50 - spacing: 2 - boxWidth: 16 - boxHeight: 16 - boxRadius: 8 - label.wrapMode: Label.NoWrap - text: qsTr("Trade price is more than 50% different to CEX! Confirm?") - font: DexTypo.caption - } - } - } - - DefaultText - { - Layout.alignment: Qt.AlignHCenter - text_value: qsTr("This swap request can not be undone and is a final event!") - font: DexTypo.italic12 - color: Dex.CurrentTheme.foregroundColor2 - } - - DefaultText - { - id: warnings_tx_time_text - Layout.alignment: Qt.AlignHCenter - text_value: qsTr("This transaction can take up to 60 mins - DO NOT close this application!") - font: DexTypo.italic12 - color: Dex.CurrentTheme.foregroundColor2 - } } ] @@ -244,6 +188,38 @@ MultipageModal } } + // Large margin warning + FloatingBackground + { + Layout.alignment: Qt.AlignCenter + width: childrenRect.width + height: childrenRect.height + color: Style.colorRed2 + visible: Math.abs(parseFloat(API.app.trading_pg.cex_price_diff)) >= 50 + + RowLayout + { + Layout.fillWidth: true + + Item { width: 3 } + + DefaultCheckBox + { + id: allow_bad_trade + Layout.alignment: Qt.AlignCenter + textColor: Style.colorWhite0 + visible: Math.abs(parseFloat(API.app.trading_pg.cex_price_diff)) >= 50 + spacing: 2 + boxWidth: 16 + boxHeight: 16 + boxRadius: 8 + label.wrapMode: Label.NoWrap + text: qsTr("Trade price is more than 50% different to CEX! Confirm?") + font: DexTypo.caption + } + } + } + // Custom config section Item { @@ -416,6 +392,31 @@ MultipageModal } } + ColumnLayout + { + id: warnings_text + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + + + DefaultText + { + Layout.alignment: Qt.AlignHCenter + text_value: qsTr("This swap request can not be undone and is a final event!") + font: DexTypo.italic12 + color: Dex.CurrentTheme.foregroundColor2 + } + + DefaultText + { + id: warnings_tx_time_text + Layout.alignment: Qt.AlignHCenter + text_value: qsTr("This transaction can take up to 60 mins - DO NOT close this application!") + font: DexTypo.italic12 + color: Dex.CurrentTheme.foregroundColor2 + } + } + Item { visible: buy_sell_rpc_busy diff --git a/src/core/atomicdex/pages/widgets/dex/qt.orderbook.cpp b/src/core/atomicdex/pages/widgets/dex/qt.orderbook.cpp index 29a50e8adf..4b702b2116 100644 --- a/src/core/atomicdex/pages/widgets/dex/qt.orderbook.cpp +++ b/src/core/atomicdex/pages/widgets/dex/qt.orderbook.cpp @@ -81,7 +81,7 @@ namespace atomic_dex void qt_orderbook_wrapper::refresh_orderbook_model_data(mm2::orderbook_result_rpc answer) { - SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] bids/asks size: {}/{}", answer.bids.size(), answer.asks.size()); + // SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] bids/asks size: {}/{}", answer.bids.size(), answer.asks.size()); this->m_asks->refresh_orderbook_model_data(answer.asks); this->m_bids->refresh_orderbook_model_data(answer.bids); const auto data = this->m_system_manager.get_system().get_bestorders_data(); @@ -91,12 +91,12 @@ namespace atomic_dex } else if (m_best_orders->rowCount() == 0) { - SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] : reset_best_orders"); + // SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] : reset_best_orders"); m_best_orders->reset_orderbook(data, true); } else { - SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] : refresh_best_orders"); + // SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] : refresh_best_orders"); m_best_orders->refresh_orderbook_model_data(data, true); } this->set_both_taker_vol(); From 7bd6127cb0d016c126aa25193844f3767b2d1b2c Mon Sep 17 00:00:00 2001 From: smk762 Date: Sat, 6 Apr 2024 21:06:28 +0800 Subject: [PATCH 26/26] Update ts for release --- .../assets/languages/atomic_defi_de.ts | 170 +++++++++--------- .../assets/languages/atomic_defi_en.ts | 168 ++++++++--------- .../assets/languages/atomic_defi_es.ts | 170 +++++++++--------- .../assets/languages/atomic_defi_fr.ts | 170 +++++++++--------- .../assets/languages/atomic_defi_ru.ts | 170 +++++++++--------- .../assets/languages/atomic_defi_tr.ts | 170 +++++++++--------- 6 files changed, 533 insertions(+), 485 deletions(-) diff --git a/atomic_defi_design/assets/languages/atomic_defi_de.ts b/atomic_defi_design/assets/languages/atomic_defi_de.ts index 20b4136a5b..dd48b90277 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_de.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_de.ts @@ -516,17 +516,17 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 Chart - + Loading pair chart data - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1412,7 +1412,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 General - + %n day(s) @@ -1420,7 +1420,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %nd day @@ -1429,7 +1429,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %nh hours @@ -1438,7 +1438,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %nm minutes @@ -1447,7 +1447,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %ns seconds @@ -1456,7 +1456,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %nms milliseconds @@ -1465,117 +1465,117 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - + %1 balance is zero - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Mindesthandelsbetrag - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1782,7 +1782,7 @@ Try again or select 'Allow custom seed' to continue. - + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 Für diese Order ist ein Mindestbetrag von %1 %2 erforderlich. <br>Ihr Guthaben reicht nicht aus.<br> %3 @@ -1940,70 +1940,70 @@ They will be removed from the orderbook until you log in again. Faucet - - - + + Vote Info + + + + + + Public Key Öffentlicher Schlüssel - + Copied to Clipboard In die Zwischenablage kopiert - + Explore - + There is no chart data for this ticker yet Für diesen Ticker liegen noch keine Chartdaten vor - + Fetching transactions... Transaktionen werden abgerufen... - + No transactions available. - + Please wait, %1 is %2 - + Loading ticker chart data - + % activated... - - Trading Information - Handelsinformationen - - - + Chart Chart - + Orders Order - + History Historie @@ -2075,6 +2075,19 @@ They will be removed from the orderbook until you log in again. Dieser Kontakt hat keine registrierte Adresse.
+ + Market + + + Orderbook + + + + + Best Orders + Die günstigsten Order + + MarketModeSelector @@ -2951,12 +2964,12 @@ Bitte wählen Sie eine neue Order aus. ProView - + Failed to place the order Die Order konnte nicht platziert werden - + Placed the order Order platziert @@ -4270,37 +4283,32 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings Pro-Ansicht Einstellungen - + Display Settings Bildschirmeinstellungen - + Ticker Selectors Ticker Selektoren - + Trading Information Handelsinformationen - - Order Book - Orderbuch - - - - Best Orders - Beste Order + + Markets + - + Place Order Order platzieren @@ -4461,8 +4469,8 @@ There is a toggle in settings where you can turn on/off the display of these tra Orderbuch - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4602,47 +4610,47 @@ This might take a few minutes... Sie benötigen %1, um das Benzin für %2 Transaktionen zu bezahlen. - + Checksum verification failed for %1. Überprüfung der Prüfsumme für %1 fehlgeschlagen. - + Invalid checksum for %1. Click the button to convert to mixed case address. Ungültige Prüfsumme für %1. Klicken Sie auf die Schaltfläche, um die Adresse in Groß-/Kleinschreibung umzuwandeln. - + Legacy address used for %1. Click the button to convert to a Cashaddress. Legacy-Adresse für %1 verwendet. Klicken Sie auf die Schaltfläche, um sie in eine Cashadresse umzuwandeln. - + %1 address must be prefixed with 0x %1 Adresse muss 0x vorangestellt werden - + %1 address length is invalid, please use a valid address. Länge der %1 Adresse ist ungültig, bitte verwenden Sie eine gültige Adresse. - + %1 address is invalid. %1 Adresse ist ungültig. - + Invalid checksum. Ungültige Prüfsumme. - + %1 address has invalid prefixes. %1 Adresse hat ungültige Vorsilben. - + Backend error: %1 Backend Fehler: %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_en.ts b/atomic_defi_design/assets/languages/atomic_defi_en.ts index 8a413639f9..2ce0fd7f4a 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_en.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_en.ts @@ -515,17 +515,17 @@ Chart - + Loading pair chart data - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1411,7 +1411,7 @@ General - + %n day(s) @@ -1419,7 +1419,7 @@ - + %nd day @@ -1428,7 +1428,7 @@ - + %nh hours @@ -1437,7 +1437,7 @@ - + %nm minutes @@ -1446,7 +1446,7 @@ - + %ns seconds @@ -1455,7 +1455,7 @@ - + %nms milliseconds @@ -1464,117 +1464,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - + %1 balance is zero - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1781,7 +1781,7 @@ Try again or select 'Allow custom seed' to continue. - + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 @@ -1939,70 +1939,70 @@ They will be removed from the orderbook until you log in again. - - - + + Vote Info + + + + + + Public Key - + Copied to Clipboard - + Explore - + There is no chart data for this ticker yet - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - + Loading ticker chart data - + % activated... - - Trading Information - - - - + Chart - + Orders - + History @@ -2074,6 +2074,19 @@ They will be removed from the orderbook until you log in again. + + Market + + + Orderbook + + + + + Best Orders + + + MarketModeSelector @@ -2949,12 +2962,12 @@ Please select a new order. ProView - + Failed to place the order - + Placed the order @@ -4260,37 +4273,32 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings - + Display Settings - + Ticker Selectors - + Trading Information - - Order Book - - - - - Best Orders + + Markets - + Place Order @@ -4451,8 +4459,8 @@ There is a toggle in settings where you can turn on/off the display of these tra - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4592,47 +4600,47 @@ This might take a few minutes... - + Checksum verification failed for %1. - + Invalid checksum for %1. Click the button to convert to mixed case address. - + Legacy address used for %1. Click the button to convert to a Cashaddress. - + %1 address must be prefixed with 0x - + %1 address length is invalid, please use a valid address. - + %1 address is invalid. - + Invalid checksum. - + %1 address has invalid prefixes. - + Backend error: %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_es.ts b/atomic_defi_design/assets/languages/atomic_defi_es.ts index e17cc56aba..d87b5995c1 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_es.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_es.ts @@ -515,17 +515,17 @@ Chart - + Loading pair chart data - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1411,7 +1411,7 @@ General - + %n day(s) @@ -1419,7 +1419,7 @@ - + %nd day @@ -1428,7 +1428,7 @@ - + %nh hours @@ -1437,7 +1437,7 @@ - + %nm minutes @@ -1446,7 +1446,7 @@ - + %ns seconds @@ -1455,7 +1455,7 @@ - + %nms milliseconds @@ -1464,117 +1464,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - + %1 balance is zero - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Cantidad Mínima de Intercambio - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1782,7 +1782,7 @@ Vuelva a intentarlo o seleccione 'Permitir semilla personalizada' pers - + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 Este pedido requiere una cantidad mínima de %1 %2 <br>No tiene fondos suficientes.<br> %3 @@ -1942,70 +1942,70 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión.Grifo - - - + + Vote Info + + + + + + Public Key Clave Pública - + Copied to Clipboard Copiada en el Portapapeles - + Explore - + There is no chart data for this ticker yet No hay datos de gráficos para este ticker aún - + Fetching transactions... Obteniendo transacciones... - + No transactions available. - + Please wait, %1 is %2 Por favor espera %1 es %2 - + Loading ticker chart data - + % activated... % activado... - - Trading Information - Información de Intercambios - - - + Chart Gráfico - + Orders Pedidos - + History Historial @@ -2077,6 +2077,19 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión.Este contacto no tiene ninguna dirección registrada. + + Market + + + Orderbook + + + + + Best Orders + Mejores Ordenes + + MarketModeSelector @@ -2953,12 +2966,12 @@ Seleccione un nuevo pedido. ProView - + Failed to place the order Error al realizar el pedido - + Placed the order Realizó el pedido El @@ -4272,37 +4285,32 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings Vista de Configuración Pro - + Display Settings Configuracion de Vista - + Ticker Selectors Selectores - + Trading Information Información de Intercambios - - Order Book - Libro de Ordenes - - - - Best Orders - Mejores Ordenes + + Markets + - + Place Order Realizar pedido @@ -4463,8 +4471,8 @@ There is a toggle in settings where you can turn on/off the display of these tra Libro de Ordenes - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4605,47 +4613,47 @@ Esto puede tardar unos minutos... Necesita tener %1 para pagar la gasolina de %2 transacciones. - + Checksum verification failed for %1. La verificación de la suma de comprobación falló para %1. - + Invalid checksum for %1. Click the button to convert to mixed case address. Suma de comprobación no válida para %1. Haga clic en el botón para convertir a dirección de mayúsculas y minúsculas. - + Legacy address used for %1. Click the button to convert to a Cashaddress. Dirección heredada utilizada para %1. Haga clic en el botón para convertir a una dirección de efectivo. - + %1 address must be prefixed with 0x La dirección %1 debe tener el prefijo 0x - + %1 address length is invalid, please use a valid address. La longitud de la dirección %1 no es válida, utilice una dirección válida. - + %1 address is invalid. La dirección %1 no es válida. - + Invalid checksum. Suma de comprobación no válida. - + %1 address has invalid prefixes. La dirección %1 tiene prefijos no válidos. - + Backend error: %1 Error de backend: %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_fr.ts b/atomic_defi_design/assets/languages/atomic_defi_fr.ts index cfc2eac0d7..d1ce976885 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_fr.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_fr.ts @@ -515,17 +515,17 @@ Chart - + Loading pair chart data - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1411,7 +1411,7 @@ General - + %n day(s) @@ -1419,7 +1419,7 @@ - + %nd day @@ -1428,7 +1428,7 @@ - + %nh hours @@ -1437,7 +1437,7 @@ - + %nm minutes @@ -1446,7 +1446,7 @@ - + %ns seconds @@ -1455,7 +1455,7 @@ - + %nms milliseconds @@ -1464,117 +1464,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - + %1 balance is zero - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Montant de trading minimum - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1781,7 +1781,7 @@ Try again or select 'Allow custom seed' to continue. - + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 Cette commande nécessite un montant minimum de %1 %2 <br>Vous n'avez pas assez de fonds.<br> %3 @@ -1939,70 +1939,70 @@ They will be removed from the orderbook until you log in again. Robinet - - - + + Vote Info + + + + + + Public Key - + Copied to Clipboard Copier dans le presse-papier - + Explore - + There is no chart data for this ticker yet Il n'y a pas encore de données graphiques pour ce ticker - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - + Loading ticker chart data - + % activated... - - Trading Information - Informations de Trading - - - + Chart Chart - + Orders Ordres - + History Historique @@ -2074,6 +2074,19 @@ They will be removed from the orderbook until you log in again. + + Market + + + Orderbook + + + + + Best Orders + Meilleurs offres + + MarketModeSelector @@ -2949,12 +2962,12 @@ Please select a new order. ProView - + Failed to place the order Échec lors du placement de l'ordre - + Placed the order L'ordre a été placé avec succès @@ -4260,37 +4273,32 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings - + Display Settings - + Ticker Selectors - + Trading Information Informations de Trading - - Order Book - Carnet d'ordres - - - - Best Orders - Meilleurs offres + + Markets + - + Place Order Placer l'ordre @@ -4451,8 +4459,8 @@ There is a toggle in settings where you can turn on/off the display of these tra Carnet d'ordres - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4592,47 +4600,47 @@ This might take a few minutes... Vous devez avoir %1 activée pour payer les frais de transactions de %2. - + Checksum verification failed for %1. Échec de la vérification du checksum de contrôle pour %1. - + Invalid checksum for %1. Click the button to convert to mixed case address. - + Legacy address used for %1. Click the button to convert to a Cashaddress. - + %1 address must be prefixed with 0x L'adresse %1 doit être précédée de 0x - + %1 address length is invalid, please use a valid address. La longueur de l'adresse %1 n'est pas valide, veuillez utiliser une adresse valide. - + %1 address is invalid. L'adresse %1 n'est pas valide. - + Invalid checksum. Somme de contrôle invalide. - + %1 address has invalid prefixes. L'adresse %1 a des préfixes non valides. - + Backend error: %1 Erreur de backend : %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_ru.ts b/atomic_defi_design/assets/languages/atomic_defi_ru.ts index b4c0cb59a6..661ad84490 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_ru.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_ru.ts @@ -515,17 +515,17 @@ Chart - + Loading pair chart data - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1411,7 +1411,7 @@ General - + %n day(s) @@ -1420,7 +1420,7 @@ - + %nd day @@ -1430,7 +1430,7 @@ - + %nh hours @@ -1440,7 +1440,7 @@ - + %nm minutes @@ -1450,7 +1450,7 @@ - + %ns seconds @@ -1460,7 +1460,7 @@ - + %nms milliseconds @@ -1470,117 +1470,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - + %1 balance is zero - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Минимальный торговый объем - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1787,7 +1787,7 @@ Try again or select 'Allow custom seed' to continue. - + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 @@ -1945,70 +1945,70 @@ They will be removed from the orderbook until you log in again. Фаусет - - - + + Vote Info + + + + + + Public Key - + Copied to Clipboard Скопировано в буфер обмена - + Explore - + There is no chart data for this ticker yet Для данного актива пока еще нет графиков данных - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - + Loading ticker chart data - + % activated... - - Trading Information - Торговая информация - - - + Chart График - + Orders Ордеры - + History История @@ -2080,6 +2080,19 @@ They will be removed from the orderbook until you log in again. + + Market + + + Orderbook + + + + + Best Orders + Лучшие ордеры + + MarketModeSelector @@ -2955,12 +2968,12 @@ Please select a new order. ProView - + Failed to place the order Не удалось разместить ордер - + Placed the order Ордер размещен @@ -4266,37 +4279,32 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings - + Display Settings - + Ticker Selectors - + Trading Information Торговая информация - - Order Book - Ордербук - - - - Best Orders - Лучшие ордеры + + Markets + - + Place Order Разместить ордер @@ -4457,8 +4465,8 @@ There is a toggle in settings where you can turn on/off the display of these tra Ордербук - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4598,47 +4606,47 @@ This might take a few minutes... Вам нужен %1 для оплаты газа за %2 транзакции. - + Checksum verification failed for %1. Checksum верфикация неуспешна для %1. - + Invalid checksum for %1. Click the button to convert to mixed case address. - + Legacy address used for %1. Click the button to convert to a Cashaddress. - + %1 address must be prefixed with 0x %1 адрес должен начинаться с 0x - + %1 address length is invalid, please use a valid address. %1 длина адреса не валидна, пожалуйста используйте валидный адрес. - + %1 address is invalid. некорректный адрес %1. - + Invalid checksum. Неверная чек-сумма. - + %1 address has invalid prefixes. у адреса %1 неверный префикс. - + Backend error: %1 Ошибка бэкенда: %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_tr.ts b/atomic_defi_design/assets/languages/atomic_defi_tr.ts index 00238a3206..ecda9ba8ef 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_tr.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_tr.ts @@ -515,17 +515,17 @@ Chart - + Loading pair chart data - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -1411,14 +1411,14 @@ General - + %n day(s) - + %nd day @@ -1426,7 +1426,7 @@ - + %nh hours @@ -1434,7 +1434,7 @@ - + %nm minutes @@ -1442,7 +1442,7 @@ - + %ns seconds @@ -1450,7 +1450,7 @@ - + %nms milliseconds @@ -1458,117 +1458,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - + %1 balance is zero - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Minimum Takas Tutarı - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1775,7 +1775,7 @@ Try again or select 'Allow custom seed' to continue. - + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 @@ -1933,70 +1933,70 @@ They will be removed from the orderbook until you log in again. Musluk - - - + + Vote Info + + + + + + Public Key - + Copied to Clipboard Panoya Kopyalandı - + Explore - + There is no chart data for this ticker yet Henüz bu hisse senedi için grafik verisi yok - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - + Loading ticker chart data - + % activated... - - Trading Information - Al Sat Bilgisi - - - + Chart Grafik - + Orders Emirler - + History Tarihçe @@ -2068,6 +2068,19 @@ They will be removed from the orderbook until you log in again. + + Market + + + Orderbook + + + + + Best Orders + En İyi Emirler + + MarketModeSelector @@ -2943,12 +2956,12 @@ Please select a new order. ProView - + Failed to place the order Emir başarısız oldu - + Placed the order Emir başarılı @@ -4254,37 +4267,32 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings - + Display Settings - + Ticker Selectors - + Trading Information Al Sat Bilgisi - - Order Book - Emir Defteri - - - - Best Orders - En İyi Emirler + + Markets + - + Place Order Emir Ver @@ -4445,8 +4453,8 @@ There is a toggle in settings where you can turn on/off the display of these tra Emir Defteri - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4586,47 +4594,47 @@ This might take a few minutes... %2 işlemi için gaz ödemek üzere %1'e sahip olmanız gerekir. - + Checksum verification failed for %1. %1 için sağlama toplamı doğrulaması başarısız oldu. - + Invalid checksum for %1. Click the button to convert to mixed case address. - + Legacy address used for %1. Click the button to convert to a Cashaddress. - + %1 address must be prefixed with 0x %1 adresinin önüne 0x konulmalı - + %1 address length is invalid, please use a valid address. %1 adres uzunluğu geçersiz, lütfen geçerli bir adres kullanın. - + %1 address is invalid. - + Invalid checksum. - + %1 address has invalid prefixes. - + Backend error: %1