diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 900c2817e3..623343db29 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -26,7 +26,7 @@ Please describe what you expected to happen. **Operating Environment(s):** - OS: [e.g. Windows/OSX/Linux. If Linux, include distro. ] - OS version: [e.g. 7/10/11, 10.13/10.15, 18.04/20.04 ] - - Komodo Wallet Version: [e.g. 0.7.0] + - Komodo Wallet Desktop Version: [e.g. 0.7.2] - Build branch: [e.g. master/dev] diff --git a/.github/workflows/firodex-desktop-cd.yml b/.github/workflows/firodex-desktop-cd.yml index 2e928193e4..d4f9e40df6 100644 --- a/.github/workflows/firodex-desktop-cd.yml +++ b/.github/workflows/firodex-desktop-cd.yml @@ -9,7 +9,7 @@ env: DEX_PROJECT_NAME: "firodex-desktop" DEX_DISPLAY_NAME: "FiroDex Desktop" DEX_COMPANY: "Firo Core Team" - DEX_VERSION: "0.7.0" + DEX_VERSION: "0.7.2" DEX_WEBSITE: "https://firo.org/" jobs: @@ -374,7 +374,7 @@ jobs: windows-release: name: Win Build/Release - runs-on: windows-latest + runs-on: windows-2019 steps: - uses: actions/checkout@v2 @@ -452,7 +452,7 @@ jobs: windows-debug: name: Win Build/Debug - runs-on: windows-latest + runs-on: windows-2019 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/firodex-desktop-ci.yml b/.github/workflows/firodex-desktop-ci.yml index 42878ba1ca..2a15220fa2 100644 --- a/.github/workflows/firodex-desktop-ci.yml +++ b/.github/workflows/firodex-desktop-ci.yml @@ -9,6 +9,7 @@ on: - master schedule: - cron: '0 0 * * 1' + workflow_dispatch: env: DEX_API: "mm2_firo" @@ -17,7 +18,7 @@ env: DEX_PROJECT_NAME: "firodex" DEX_DISPLAY_NAME: "Firo Dex" DEX_COMPANY: "Firo" - DEX_VERSION: "0.7.0" + DEX_VERSION: "0.7.2" DEX_WEBSITE: "https://firo.org/" VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/b/vcpkg_cache VCPKG_BINARY_SOURCES: clear;x-gha,readwrite @@ -68,13 +69,13 @@ jobs: host: 'mac' - name: windows-release - os: windows-latest + os: windows-2019 qt: '5.15.2' type: 'Release' host: 'windows' - name: windows-debug - os: windows-latest + os: windows-2019 qt: '5.15.2' type: 'Debug' host: 'windows' 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d3b3eeb8..27a70b272e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ include(vcpkg_prerequisites) include(qt_prerequisites) include(cfg_hash) -project(${DEX_PROJECT_NAME} LANGUAGES CXX VERSION 0.7.0) +project(${DEX_PROJECT_NAME} LANGUAGES CXX VERSION 0.7.2) message(STATUS "${PROJECT_NAME} is version ${PROJECT_VERSION}") include(cmake_default_options) @@ -60,13 +60,13 @@ endif () ##! We fetch our dependencies if (APPLE) FetchContent_Declare(mm2 - URL https://sdk.devbuilds.komodo.earth/main/mm2_b0fd99e-mac-x86-64.zip) + URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v2.0.0-beta/mm2-b0fd99e84-Darwin-Release.zip) elseif (UNIX AND NOT APPLE) FetchContent_Declare(mm2 - URL https://sdk.devbuilds.komodo.earth/main/mm2_b0fd99e-linux-x86-64.zip) + URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v2.0.0-beta/mm2-b0fd99e84-Linux-Release.zip) else () FetchContent_Declare(mm2 - URL https://sdk.devbuilds.komodo.earth/main/mm2_b0fd99e-win-x86-64.zip) + URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v2.0.0-beta/mm2-b0fd99e84-Win64.zip) endif () #FetchContent_Declare(qmaterial URL https://github.com/KomodoPlatform/Qaterial/archive/last-clang-working-2.zip) diff --git a/assets/config/cfg.json b/assets/config/cfg.json index d6704a8f55..0dc1052fd5 100644 --- a/assets/config/cfg.json +++ b/assets/config/cfg.json @@ -1,6 +1,7 @@ { "notification_enabled": true, "spamfilter_enabled": false, + "postorder_enabled": false, "use_static_rpcpass": false, "current_currency": "USD", "current_fiat": "USD", diff --git a/atomic_defi_design/Dex/Addressbook/Main.qml b/atomic_defi_design/Dex/Addressbook/Main.qml index fba4df4df4..6784d69df3 100644 --- a/atomic_defi_design/Dex/Addressbook/Main.qml +++ b/atomic_defi_design/Dex/Addressbook/Main.qml @@ -120,6 +120,13 @@ Item } } + Dex.Text { + visible: contactTable.count == 0 + Layout.fillWidth: true + Layout.fillHeight: true + text: qsTr("No contacts found.") + } + // Contact table content Dex.DefaultListView { 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/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/Constants/General.qml b/atomic_defi_design/Dex/Constants/General.qml index d57eeb99de..d9625cdb59 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 @@ -566,7 +571,7 @@ QtObject { } return diffPrefix(received) + (fiat === API.app.settings_pg.current_fiat ? API.app.settings_pg.current_fiat_sign : API.app.settings_pg.current_currency_sign) - + " " + (amount < 1E5 ? formatDouble(parseFloat(amount), precision, true) : nFormatter(parseFloat(amount), 2)) + + " " + (amount < 1E5 ? formatDouble(parseFloat(amount), precision, true) : nFormatter(parseFloat(amount), precision)) } function formatPercent(value, show_prefix=true) { diff --git a/atomic_defi_design/Dex/Exchange/ProView/Chart.qml b/atomic_defi_design/Dex/Exchange/ProView/Chart.qml index 80766a3d06..69480206f4 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/Chart.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/Chart.qml @@ -37,12 +37,14 @@ Item { pair_supported = false selected_testcoin = left_ticker + console.log("no chart, testcoin", selected_testcoin) return } if (General.is_testcoin(right_ticker)) { pair_supported = false selected_testcoin = right_ticker + console.log("no chart, testcoin", selected_testcoin) return } @@ -52,9 +54,13 @@ Item { pair_supported = true symbol = rel_ticker+"-"+base_ticker + console.log("symbol", symbol) + console.log("loaded_symbol", loaded_symbol) + if (symbol === loaded_symbol && !force) { webEngineViewPlaceHolder.visible = true + console.log("symbol === loaded_symbol, ok") return } chart_html = ` @@ -64,13 +70,14 @@ Item transform: scale(${Math.min(scale_x, scale_y)}); transform-origin: top left; } + a { pointer-events: none; }
` } } - // console.log(chart_html) + console.log(chart_html) if (chart_html == "") { @@ -84,6 +91,7 @@ Item if (!symbol) { pair_supported = false + console.log("pair not supported", pair, pair_reversed) return } @@ -165,7 +173,7 @@ Item DefaultText { visible: pair_supported - text_value: qsTr("Loading market data") + "..." + text_value: qsTr("Loading pair chart data") + "..." } DefaultText @@ -190,7 +198,7 @@ Item id: webEngineViewPlaceHolder anchors.fill: parent anchors.centerIn: parent - visible: false + visible: true Component.onCompleted: { @@ -219,6 +227,16 @@ Item } } + MouseArea { + id: chart_mousearea + anchors.fill: webEngineViewPlaceHolder + onClicked: { + if (webEngineView.visible) { + Qt.openUrlExternally("https://www.livecoinwatch.com") + } + } + } + Connections { target: app 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..f89056a9eb 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml @@ -11,20 +11,29 @@ 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 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 + property int takerOrderform_idx: 0 + property int makerOrderform_idx: 1 - 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() + takerForm.dexErrors.text_value = "" + makerForm.dexErrors.text_value = "" + } Connections { target: API.app.trading_pg @@ -59,257 +68,135 @@ Widget } } - function reset_fees_state() + Timer { - show_waiting_for_trade_preimage = false; - check_trade_preimage.stop() - loop_count = 0 - API.app.trading_pg.reset_fees() - errors.text_value = "" + id: check_trade_preimage + interval: 500; + running: false; + repeat: true; + triggeredOnStart: true; + onTriggered: { + loop_count++; + console.log("Getting fees info... " + loop_count + "/50") + if (trade_preimage_ready) + { + show_waiting_for_trade_preimage = false + loop_count = 0 + stop() + confirm_trade_modal.open() + } + else if (trade_preimage_error != "") + { + loop_count = 0 + takerForm.dexErrors.text_value = trade_preimage_error.toString() + makerForm.dexErrors.text_value = trade_preimage_error.toString() + show_waiting_for_trade_preimage = false + stop() + } + else if (loop_count > 50) + { + loop_count = 0 + show_waiting_for_trade_preimage = false + trade_preimage_error = "Trade preimage timed out, try again." + stop() + } + } } - // Market mode selector - RowLayout + Qaterial.LatoTabBar { - Layout.topMargin: 5 - Layout.bottomMargin: 2 - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - height: 32 + id: orderformTabView - MarketModeSelector + background: null + Layout.leftMargin: 6 + + Qaterial.LatoTabButton { - 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) + text: qsTr("Taker Order") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor } - - Item { Layout.fillWidth: true } - - MarketModeSelector + Qaterial.LatoTabButton { - Layout.alignment: Qt.AlignRight - Layout.preferredWidth: (parent.width / 100) * 46 - Layout.preferredHeight: 32 - ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + text: qsTr("Maker Order") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor } } - // Protocol text for platform tokens - Item + Rectangle { - height: 32 - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - visible: protocolIcon != "" + Layout.fillHeight: true + color: Dex.CurrentTheme.floatingBackgroundColor + radius: 10 + Layout.preferredWidth: 305 - ColumnLayout + Qaterial.SwipeView { - spacing: 2 + id: orderformSwipeView + clip: true + interactive: false + currentIndex: orderformTabView.currentIndex anchors.fill: parent - anchors.centerIn: parent - Dex.Text + onCurrentIndexChanged: { - id: protocolTitle - Layout.preferredWidth: parent.width - text_value: "Protocol:" - font.pixelSize: Style.textSizeSmall1 - horizontalAlignment: Text.AlignHCenter - color: Style.colorText2 + API.app.trading_pg.maker_mode = currentIndex === makerOrderform_idx ? true : false + orderformSwipeView.currentItem.update() + API.app.trading_pg.reset_order() + reset_fees_state() } - RowLayout + Item { - id: protocol - Layout.alignment: Qt.AlignHCenter - - DefaultImage - { - id: protocolImg - source: protocolIcon - Layout.preferredHeight: 16 - Layout.preferredWidth: Layout.preferredHeight - } + id: takerOrderform - DexLabel + OrderForm { - id: protocolText - text_value: General.getProtocolText(left_ticker) - wrapMode: DexLabel.NoWrap - font.pixelSize: Style.textSizeSmall1 - color: Style.colorText2 + 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 } } - } - } - - // Order selected indicator - Item - { - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - height: 32 - - RowLayout - { - id: orderSelection - visible: API.app.trading_pg.preferred_order.price !== undefined - anchors.fill: parent - anchors.verticalCenter: parent.verticalCenter - DefaultText + Item { - Layout.leftMargin: 15 - color: Dex.CurrentTheme.warningColor - text: qsTr("Order Selected") - } - - Item { Layout.fillWidth: true } + id: makerOrderform - 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 + OrderForm { - anchors.centerIn: parent - iconSize: 16 - color: Dex.CurrentTheme.warningColor - source: Qaterial.Icons.close + id: makerForm + width: parent.width + height: 330 + Layout.alignment: Qt.AlignHCenter + 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() + } + swap_btn_spinner.visible: show_waiting_for_trade_preimage } } } - - Rectangle - { - visible: API.app.trading_pg.preferred_order.price !== undefined - anchors.fill: parent - radius: 8 - color: 'transparent' - border.color: Dex.CurrentTheme.warningColor - } - } - - 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 - { - 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; - repeat: true; - triggeredOnStart: true; - onTriggered: { - loop_count++; - console.log("Getting fees info... " + loop_count + "/50") - if (trade_preimage_ready) - { - show_waiting_for_trade_preimage = false - loop_count = 0 - stop() - confirm_trade_modal.open() - } - else if (trade_preimage_error != "") - { - loop_count = 0 - errors.text_value = trade_preimage_error.toString() - show_waiting_for_trade_preimage = false - stop() - } - else if (loop_count > 50) - { - loop_count = 0 - show_waiting_for_trade_preimage = false - trade_preimage_error = "Trade preimage timed out, try again." - stop() - } - } } -} +} \ No newline at end of file diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml index b4ffbdbf17..799e0b8a15 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/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/ProView/PlaceOrderForm/OrderForm.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml index 3e508ca18c..1cc7440e66 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml @@ -2,14 +2,21 @@ 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 +import AtomicDEX.MarketMode 1.0 as Dex ColumnLayout { id: root + anchors.horizontalCenter: parent.horizontalCenter + anchors.fill: parent + anchors.margins: 20 spacing: 8 function focusVolumeField() @@ -20,6 +27,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 @@ -52,6 +62,37 @@ 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 + visible: !API.app.trading_pg.maker_mode + + 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 @@ -263,4 +304,121 @@ 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 + } + + DefaultBusyIndicator + { + id: swap_btn_spinner + Layout.alignment: Qt.AlignHCenter + indicatorSize: 28 + indicatorDotSize: 4 + } + Item + { + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: parent.width - 16 + height: 28 + + DexGradientAppButton + { + id: swap_btn + height: 32 + anchors.fill: parent + 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/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 0c520adfcf..3246d7b555 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml @@ -5,27 +5,19 @@ 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" import "../../ProView" -Widget +ColumnLayout { - width: 450 + Layout.preferredWidth: 450 + Layout.fillHeight: true property alias currentIndex: tabView.currentIndex - title: qsTr("Trading Information") - - background: null - margins: 0 - - Connections - { - target: exchange_trade - function onOrderSelected() { tabView.currentIndex = 0; } - } - Qaterial.LatoTabBar { id: tabView @@ -81,7 +73,19 @@ Widget { 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 + } + // Chart Chart { @@ -102,6 +106,7 @@ Widget Layout.rightMargin: 5 Layout.fillWidth: true Layout.fillHeight: true + width: 435 } } diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml index 2c0f7854c1..df4d38f8a7 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 : "" @@ -119,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/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/BestOrder/List.qml b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml index 85a7be4ebe..552ee7bbff 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml @@ -14,9 +14,11 @@ 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 Header { diff --git a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml index e5893f2e31..be08030d7a 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 { @@ -170,15 +169,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/ConfirmTradeModal.qml b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml index 4054ef6606..8056ecbef9 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 - 480 + flickMax: window.height - 385 header: [ RowLayout @@ -43,6 +44,7 @@ MultipageModal PairItemBadge { ticker: base_ticker + is_left: true fullname: General.coinName(base_ticker) amount: base_amount Layout.fillHeight: true @@ -75,59 +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!") - } - - 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.pixelSize: Style.textSizeSmall4 - } } ] @@ -138,9 +87,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 +188,39 @@ MultipageModal } } - // Custom config checkbox + // 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 { Layout.alignment: Qt.AlignCenter @@ -251,9 +232,30 @@ MultipageModal { id: use_custom 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 + height: 40 + text: qsTr("Good until cancelled (order will remain on orderbook until filled or cancelled)") + } + DefaultCheckBox { id: enable_custom_config @@ -261,7 +263,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) @@ -390,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 @@ -437,7 +464,9 @@ 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, + 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/Market.qml b/atomic_defi_design/Dex/Exchange/Trade/Market.qml new file mode 100644 index 0000000000..3c6af075e6 --- /dev/null +++ b/atomic_defi_design/Dex/Exchange/Trade/Market.qml @@ -0,0 +1,85 @@ +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 + } + + // Best Orders + BestOrder.List + { + id: bestOrders + } + } + } +} diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml index 23e54d6606..8807c1a69c 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml @@ -12,7 +12,6 @@ Item id: _control property bool isAsk - property bool isVertical: false width: parent.width height: parent.height @@ -25,10 +24,15 @@ Item clip: true reuseItems: true spacing: 8 + opacity: API.app.trading_pg.maker_mode ? 0.6 : 1 onContentHeightChanged: { - if (isVertical) _tm.start(); + if (isAsk){ + // Duplication is intended. Sometimes data takes too long to load so slowscroll is a backup. + slowscroll_timer.start(); + quickscroll_timer.start() + } } delegate: Item @@ -46,12 +50,50 @@ Item Timer { - id: _tm - interval: 2000 + id: slowscroll_timer + interval: 1500 onTriggered: { orderbook_list.positionViewAtEnd() } } + Timer + { + id: quickscroll_timer + interval: 500 + onTriggered: + { + orderbook_list.positionViewAtEnd() + } + } + onModelChanged: { + if (isAsk) quickscroll_timer.start() + } + } + + Connections { + target: API.app.trading_pg; + + function onMarketModeChanged() + { + if (isAsk) + { + quickscroll_timer.start() + } + } + function onOrderbookChanged() + { + if (isAsk) + { + quickscroll_timer.start() + } + } + function onMarketPairsChanged() + { + if (isAsk) + { + quickscroll_timer.start() + } + } } } \ No newline at end of file diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml index 5ce557fc6b..03819d17fe 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 @@ -44,6 +45,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); @@ -101,9 +106,11 @@ Item anchors.fill: parent hoverEnabled: true + // Populate form with selected order onClicked: { if (is_mine) return + if (API.app.trading_pg.maker_mode) return if (enough_funds_to_pay_min_volume ) { @@ -119,6 +126,7 @@ Item } } + // Highlight row on mouseover AnimatedRectangle { visible: mouse_area.containsMouse @@ -128,16 +136,6 @@ Item opacity: 0.1 } - 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 { @@ -161,98 +159,111 @@ Item } } - Row + // Price, Qty & Total text values + RowLayout { id: row anchors.fill: parent - anchors.horizontalCenter: parent.horizontalCenter onWidthChanged: progress.width = ((depth * 100) * (width + 40)) / 100 - spacing: 0 + 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 } - Item { width: parent.width * 0.01 } - // Quantity Dex.ElidableText { - anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.37 + 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 } - Item { width: parent.width * 0.01 } - // Total Dex.ElidableText { - anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.30 - rightPadding: (is_mine) && (mouse_area.containsMouse || cancel_button.containsMouse) ? 30 : 0 + id: total_text + 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 } } } - } - } - - 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 - } - } - - iconSize: mouse_area.containsMouse || cancel_button.containsMouse? 16 : 0 + id: cancel_flat_btn + Layout.fillHeight: true + width: 30 + Layout.alignment: Qt.AlignVCenter - color: cancel_button.containsMouse ? - Qaterial.Colors.red : mouse_area.containsMouse ? - DexTheme.foregroundColor: Qaterial.Colors.red + MouseArea + { + id: cancel_mouse_area + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + } - DefaultMouseArea - { - id: cancel_button - anchors.fill: parent - hoverEnabled: true + Qaterial.FlatButton + { + id: cancel_button_orderbook + anchors.centerIn: parent + anchors.fill: parent + opacity: is_mine ? 1 : 0 - onClicked: - { - if (!is_mine) return + onClicked: { + if (uuid) cancelOrder(uuid); + } - cancel_button_text.requested_cancel = true - cancelOrder(uuid) + Qaterial.ColorIcon + { + anchors.centerIn: parent + iconSize: 16 + color: Dex.CurrentTheme.warningColor + source: Qaterial.Icons.close + visible: is_mine + scale: is_mine && mouse_area.containsMouse ? 1 : 0 + Behavior on scale { NumberAnimation { duration: 150 } } + } + } } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml index b73167e100..a32347e739 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml @@ -11,12 +11,14 @@ 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 { @@ -27,7 +29,6 @@ Widget List { isAsk: true - isVertical: true Layout.fillHeight: true Layout.fillWidth: true } @@ -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/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 - } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml index 0483903ffb..88e66b9641 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml @@ -40,10 +40,8 @@ RowLayout { id: form - 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( @@ -104,77 +102,34 @@ RowLayout General.prettifyJSON(response.result), false) General.prevent_coin_disabling.restart() - tradingInfo.currentIndex = 1 + // Show the orders tab unless settings say otherwise + if (API.app.settings_pg.postorder_enabled) + { + tradingInfo.currentIndex = 1 + } } } } - ColumnLayout + // Trading Informations + TradingInfo.Main { + id: tradingInfo 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.minimumWidth: tradingInfo.visible ? 450 : -1 + Layout.maximumWidth: (!marketsOrderBook.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.fillWidth: true - 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. @@ -186,13 +141,11 @@ RowLayout Layout.maximumWidth: 305 Layout.fillWidth: true Layout.fillHeight: true - - resizable: false } ModalLoader { id: confirm_trade_modal - sourceComponent: ConfirmTradeModal {} + sourceComponent: ConfirmTradeModal { } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Main.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Main.qml index 6d52f44351..feb3ebd7ff 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Main.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Main.qml @@ -29,7 +29,10 @@ Item target: exchange_trade function onOrderPlaced() { - currentSubPage = subPages.Orders + if (API.app.settings_pg.postorder_enabled) + { + currentSubPage = subPages.Orders + } } } 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 1923050189..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) + { + 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) + { + API.app.trading_pg.place_buy_order(nota, confs, options.good_until_canceled) + } orderPlaced() } @@ -170,10 +186,8 @@ Item width: parent.width height: parent.height * 0.06 - 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..f92fc23130 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml @@ -19,10 +19,8 @@ import "../../../Constants" Item { // property var proViewChart - property var proViewTickerSelectors property var proViewTrInfo - property var proViewOrderBook - property var proViewBestOrders + property var proViewMarketsOrderBook property var proViewPlaceOrderForm Item @@ -35,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 @@ -91,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: { @@ -111,35 +110,27 @@ 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 } - 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("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 } } } } diff --git a/atomic_defi_design/Dex/Settings/SettingModal.qml b/atomic_defi_design/Dex/Settings/SettingModal.qml index 332e245c6b..246d38c9b3 100644 --- a/atomic_defi_design/Dex/Settings/SettingModal.qml +++ b/atomic_defi_design/Dex/Settings/SettingModal.qml @@ -482,6 +482,32 @@ Qaterial.Dialog } } } + + // Post-order placement toggle + RowLayout + { + width: parent.width - 30 + anchors.horizontalCenter: parent.horizontalCenter + height: 50 + + DexLabel + { + Layout.alignment: Qt.AlignVCenter + Layout.fillWidth: true + font: DexTypo.subtitle1 + text: qsTr("Show orders after placement") + } + + Item { Layout.fillWidth: true } + + DexSwitch + { + Layout.alignment: Qt.AlignVCenter + Component.onCompleted: checked = API.app.settings_pg.postorder_enabled + onCheckedChanged: API.app.settings_pg.postorder_enabled = checked + } + } + } } Item diff --git a/atomic_defi_design/Dex/Wallet/Main.qml b/atomic_defi_design/Dex/Wallet/Main.qml index 497e117274..7028d16c2b 100644 --- a/atomic_defi_design/Dex/Wallet/Main.qml +++ b/atomic_defi_design/Dex/Wallet/Main.qml @@ -657,6 +657,53 @@ 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: { + let url = "https://vote.komodoplatform.com/" + api_wallet_page.ticker.toLowerCase() + "/"; + Qt.openUrlExternally(url); + } + + 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: "#2c87b9" + } + } + } + + // 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() } @@ -932,7 +979,7 @@ Item DefaultText { - text_value: qsTr("Loading market data") + "..." + text_value: qsTr("Loading ticker chart data") + "..." } } diff --git a/atomic_defi_design/Dex/Wallet/SendModal.qml b/atomic_defi_design/Dex/Wallet/SendModal.qml index 2fcd8effc9..aedb0f7682 100644 --- a/atomic_defi_design/Dex/Wallet/SendModal.qml +++ b/atomic_defi_design/Dex/Wallet/SendModal.qml @@ -509,7 +509,7 @@ MultipageModal { id: fiat_symbol visible: _preparePage.cryptoSendMode && API.app.settings_pg.current_currency_sign != "KMD" - font.pixelSize: 18 + font.pixelSize: API.app.settings_pg.current_currency_sign.length == 1 ? 18 : 18 - API.app.settings_pg.current_currency_sign.length * 2 anchors.centerIn: parent text: API.app.settings_pg.current_currency_sign } @@ -520,7 +520,7 @@ MultipageModal anchors.centerIn: parent width: 18 height: 18 - source: General.coinIcon(API.app.wallet_pg.ticker) + source: _preparePage.cryptoSendMode ? General.coinIcon(API.app.settings_pg.current_currency_sign) : General.coinIcon(API.app.wallet_pg.ticker) } } diff --git a/atomic_defi_design/assets/languages/atomic_defi_de.ts b/atomic_defi_design/assets/languages/atomic_defi_de.ts index bc1f6fc053..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 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 @@ -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 - - Loading market data - Laden von Marktdaten - - - + 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 - - % activated... + + Loading ticker chart data - - Trading Information - Handelsinformationen + + % activated... + - + 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,26 +2050,44 @@ 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. + + Market + + + Orderbook + + + + + Best Orders + Die günstigsten Order + + MarketModeSelector @@ -2946,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 @@ -4265,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 @@ -4456,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 @@ -4597,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 d81cf703c8..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 market data + + 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. - - - - Public Key + + Vote Info - - Copied to Clipboard + + + + Public Key - - Explore + + Copied to Clipboard - - Loading market data + + Explore - + There is no chart data for this ticker yet - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - - % activated... + + Loading ticker chart data - - Trading Information + + % activated... - + Chart - + Orders - + History @@ -2024,7 +2024,7 @@ They will be removed from the orderbook until you log in again. - + Address Book @@ -2049,26 +2049,44 @@ 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. + + Market + + + Orderbook + + + + + Best Orders + + + MarketModeSelector @@ -2944,12 +2962,12 @@ Please select a new order. ProView - + Failed to place the order - + Placed the order @@ -4255,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 @@ -4446,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 @@ -4587,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 1e38882cd1..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 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 @@ -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 - - Loading market data - Cargando datos de mercado - - - + 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 - - % activated... - % activado... + + Loading ticker chart data + - - Trading Information - Información de Intercambios + + % activated... + % activado... - + 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,26 +2052,44 @@ 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. + + Market + + + Orderbook + + + + + Best Orders + Mejores Ordenes + + MarketModeSelector @@ -2948,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 @@ -4267,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 @@ -4458,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 @@ -4600,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 cbb1fa663d..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 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 @@ -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 - - Loading market data - Chargement des données de marché - - - + 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 - - % activated... + + Loading ticker chart data - - Trading Information - Informations de Trading + + % activated... + - + 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,26 +2049,44 @@ 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. + + Market + + + Orderbook + + + + + Best Orders + Meilleurs offres + + MarketModeSelector @@ -2944,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 @@ -4255,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 @@ -4446,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 @@ -4587,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 718b15dcf5..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 market data - Загрузка рыночных данных + + 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 - - Loading market data - Загрузка рыночных данных - - - + There is no chart data for this ticker yet Для данного актива пока еще нет графиков данных - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - - % activated... + + Loading ticker chart data - - Trading Information - Торговая информация + + % activated... + - + Chart График - + Orders Ордеры - + History История @@ -2030,7 +2030,7 @@ They will be removed from the orderbook until you log in again. - + Address Book Адресная книга @@ -2055,26 +2055,44 @@ 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. + + Market + + + Orderbook + + + + + Best Orders + Лучшие ордеры + + MarketModeSelector @@ -2950,12 +2968,12 @@ Please select a new order. ProView - + Failed to place the order Не удалось разместить ордер - + Placed the order Ордер размещен @@ -4261,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 Разместить ордер @@ -4452,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 @@ -4593,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 4b7e47216f..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 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 @@ -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 - - Loading market data - Piyasa bilgisi yükleniyor - - - + 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 - - % activated... + + Loading ticker chart data - - Trading Information - Al Sat Bilgisi + + % activated... + - + 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,26 +2043,44 @@ 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. + + Market + + + Orderbook + + + + + Best Orders + En İyi Emirler + + MarketModeSelector @@ -2938,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ı @@ -4249,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 @@ -4440,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 @@ -4581,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 diff --git a/cmake/project.metadata.cmake b/cmake/project.metadata.cmake index 52731c3f45..109a9f1543 100644 --- a/cmake/project.metadata.cmake +++ b/cmake/project.metadata.cmake @@ -6,7 +6,7 @@ set(DEX_PROJECT_NAME "firodex") set(DEX_DISPLAY_NAME "Firo Dex") set(DEX_MAINTENANCE_TOOL_NAME "Firo Dex Maintenance Tool") set(DEX_COMPANY "Firo") -set(DEX_VERSION "0.7.0") +set(DEX_VERSION "0.7.2") set(DEX_WEBSITE "https://firo.org/") set(DEX_SUPPORT_PAGE "https://firo.org/guide/") set(DEX_DISCORD "https://discord.com/invite/TGZPRbRT3Y") 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/api/komodo_prices/komodo.prices.cpp b/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp index a2282bb4ae..24032437d9 100644 --- a/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp +++ b/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp @@ -10,7 +10,7 @@ namespace { - constexpr const char* g_komodo_prices_endpoint = "https://defi-stats.komodo.earth"; + constexpr const char* g_komodo_prices_endpoint = "https://cache.defi-stats.komodo.earth"; constexpr const char* g_komodo_prices_endpoint_fallback = "https://prices.cipig.net:1717"; web::http::client::http_client_config g_komodo_prices_cfg{[]() @@ -79,7 +79,7 @@ namespace atomic_dex::komodo_prices::api { web::http::http_request req; req.set_method(web::http::methods::GET); - std::string endpoint = fallback ? "api/v2/tickers?expire_at=21600" : "api/v3/prices/tickers_v2?expire_at=21600"; + std::string endpoint = fallback ? "api/v2/tickers?expire_at=21600" : "api/v3/prices/tickers_v2.json?expire_at=21600"; if (fallback) { SPDLOG_INFO("url: {}", TO_STD_STR(g_komodo_prices_client_fallback->base_uri().to_string()) + endpoint); diff --git a/src/core/atomicdex/api/mm2/mm2.client.cpp b/src/core/atomicdex/api/mm2/mm2.client.cpp index 151066275d..3be3af8d99 100644 --- a/src/core/atomicdex/api/mm2/mm2.client.cpp +++ b/src/core/atomicdex/api/mm2/mm2.client.cpp @@ -78,11 +78,7 @@ namespace Rpc process_rpc_answer(const web::http::http_response& answer) { std::string body = TO_STD_STR(answer.extract_string(true).get()); - if (body.size() > 1000) - { - SPDLOG_DEBUG("redacted rpc answer: {}", body.substr(0, 1000)); - } - SPDLOG_DEBUG("body: {}", body); + // SPDLOG_DEBUG("body: {}", body); nlohmann::json json_answer; Rpc rpc; try 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/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/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/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/config/app.cfg.cpp b/src/core/atomicdex/config/app.cfg.cpp index 78ec9fda01..50f16d1cc2 100644 --- a/src/core/atomicdex/config/app.cfg.cpp +++ b/src/core/atomicdex/config/app.cfg.cpp @@ -50,6 +50,7 @@ namespace config_json_data["available_signs"] = config.available_currency_signs; config_json_data["notification_enabled"] = config.notification_enabled; config_json_data["spamfilter_enabled"] = config.spamfilter_enabled; + config_json_data["postorder_enabled"] = config.postorder_enabled; config_json_data["static_rpcpass_enabled"] = config.static_rpcpass_enabled; file.close(); @@ -85,6 +86,15 @@ namespace atomic_dex config.spamfilter_enabled = true; } + if (j.contains("postorder_enabled")) + { + j.at("postorder_enabled").get_to(config.postorder_enabled); + } + else + { + config.postorder_enabled = true; + } + if (j.contains("static_rpcpass_enabled")) { j.at("static_rpcpass_enabled").get_to(config.static_rpcpass_enabled); @@ -105,6 +115,16 @@ namespace atomic_dex } } + void + change_postorder_status(cfg& config, bool is_enabled) + { + if (config.postorder_enabled != is_enabled) + { + config.postorder_enabled = is_enabled; + upgrade_cfg(config); + } + } + void change_spamfilter_status(cfg& config, bool is_enabled) { @@ -165,7 +185,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 +193,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/config/app.cfg.hpp b/src/core/atomicdex/config/app.cfg.hpp index 550a182386..d707ee02d5 100644 --- a/src/core/atomicdex/config/app.cfg.hpp +++ b/src/core/atomicdex/config/app.cfg.hpp @@ -32,6 +32,7 @@ namespace atomic_dex std::vector recommended_fiat; std::vector possible_currencies; bool notification_enabled; + bool postorder_enabled{false}; bool spamfilter_enabled{false}; bool static_rpcpass_enabled{false}; }; @@ -40,6 +41,7 @@ namespace atomic_dex void change_currency(cfg& config, const std::string& new_currency); void change_fiat(cfg& config, const std::string& new_fiat); void change_notification_status(cfg& config, bool is_enabled); + void change_postorder_status(cfg& config, bool is_enabled); void change_spamfilter_status(cfg& config, bool is_enabled); void change_static_rpcpass_status(cfg& config, bool is_enabled); [[nodiscard]] bool is_this_currency_a_fiat(const cfg& config, const std::string& currency); diff --git a/src/core/atomicdex/config/coins.cfg.cpp b/src/core/atomicdex/config/coins.cfg.cpp index 1f846b5376..9f0d9c806b 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; @@ -286,21 +292,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 +326,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/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 3eee59006c..327bb34ddc 100644 --- a/src/core/atomicdex/constants/dex.constants.hpp +++ b/src/core/atomicdex/constants/dex.constants.hpp @@ -19,12 +19,21 @@ namespace atomic_dex "BUSD-BEP20", "USDC-BEP20", "USDT-BEP20" + "VOTE2024", }; inline const std::vector g_faucet_coins{ "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", @@ -32,7 +41,10 @@ namespace atomic_dex "PAXG-ERC20", "USDT-ERC20", "XPM", - "VOTE2023", + "KIP0002", + "KIP0003", + "KIP0004", + "VOTE2024", "ATOM" }; } 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.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/models/qt.orderbook.proxy.model.cpp b/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp index 28b47ab518..6117bf3eb9 100644 --- a/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp +++ b/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp @@ -155,23 +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 (left_coin_info.is_testnet.value_or(false)) + { + 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/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: diff --git a/src/core/atomicdex/models/qt.portfolio.model.cpp b/src/core/atomicdex/models/qt.portfolio.model.cpp index 55b6557f2f..6c0b8bc922 100644 --- a/src/core/atomicdex/models/qt.portfolio.model.cpp +++ b/src/core/atomicdex/models/qt.portfolio.model.cpp @@ -109,6 +109,8 @@ namespace atomic_dex bool portfolio_model::update_activation_status() { + // This feels a bit heavy handed. There should be a better way to do this. + // Function may be unused. const auto& mm2_system = this->m_system_manager.get_system(); const auto coins = this->m_system_manager.get_system().get_global_cfg()->get_enabled_coins(); diff --git a/src/core/atomicdex/pages/qt.settings.page.cpp b/src/core/atomicdex/pages/qt.settings.page.cpp index 9ff8af5085..e8a74389bb 100644 --- a/src/core/atomicdex/pages/qt.settings.page.cpp +++ b/src/core/atomicdex/pages/qt.settings.page.cpp @@ -226,6 +226,20 @@ namespace atomic_dex } } + bool atomic_dex::settings_page::is_postorder_enabled() const + { + return m_config.postorder_enabled; + } + + void settings_page::set_postorder_enabled(bool is_enabled) + { + if (m_config.postorder_enabled != is_enabled) + { + change_postorder_status(m_config, is_enabled); + emit onPostOrderEnabledChanged(); + } + } + bool atomic_dex::settings_page::is_notification_enabled() const { return m_config.notification_enabled; @@ -647,7 +661,7 @@ namespace atomic_dex out["adex_cfg"][ticker]["explorer_url"] = coin_info.explorer_url; out["adex_cfg"][ticker]["fallback_swap_contract"] = coin_info.swap_contract_address; out["adex_cfg"][ticker]["fname"] = name_lowercase; - out["adex_cfg"][ticker]["is_testnet"] = true; + out["adex_cfg"][ticker]["is_testnet"] = false; out["adex_cfg"][ticker]["currently_enabled"] = false; out["adex_cfg"][ticker]["mm2"] = 1; out["adex_cfg"][ticker]["name"] = name_lowercase; diff --git a/src/core/atomicdex/pages/qt.settings.page.hpp b/src/core/atomicdex/pages/qt.settings.page.hpp index 5ce98412a7..fa37ddd804 100644 --- a/src/core/atomicdex/pages/qt.settings.page.hpp +++ b/src/core/atomicdex/pages/qt.settings.page.hpp @@ -46,6 +46,7 @@ namespace atomic_dex Q_PROPERTY(QString current_fiat READ get_current_fiat WRITE set_current_fiat NOTIFY onFiatChanged) Q_PROPERTY(bool notification_enabled READ is_notification_enabled WRITE set_notification_enabled NOTIFY onNotificationEnabledChanged) Q_PROPERTY(bool spamfilter_enabled READ is_spamfilter_enabled WRITE set_spamfilter_enabled NOTIFY onSpamFilterEnabledChanged) + Q_PROPERTY(bool postorder_enabled READ is_postorder_enabled WRITE set_postorder_enabled NOTIFY onPostOrderEnabledChanged) Q_PROPERTY(bool static_rpcpass_enabled READ is_static_rpcpass_enabled WRITE set_static_rpcpass_enabled NOTIFY onStaticRpcPassEnabledChanged) Q_PROPERTY(QVariant custom_token_data READ get_custom_token_data WRITE set_custom_token_data NOTIFY customTokenDataChanged) Q_PROPERTY(bool fetching_custom_token_data_busy READ is_fetching_custom_token_data_busy WRITE set_fetching_custom_token_data_busy NOTIFY customTokenDataStatusChanged) @@ -94,6 +95,8 @@ namespace atomic_dex bool set_zhtlc_status(nlohmann::json data); [[nodiscard]] bool is_spamfilter_enabled() const; void set_spamfilter_enabled(bool is_enabled); + [[nodiscard]] bool is_postorder_enabled() const; + void set_postorder_enabled(bool is_enabled); void set_current_currency(const QString& current_currency); void set_current_fiat(const QString& current_fiat); [[nodiscard]] bool is_fetching_custom_token_data_busy() const; @@ -143,6 +146,7 @@ namespace atomic_dex void onFiatSignChanged(); void onFiatChanged(); void onNotificationEnabledChanged(); + void onPostOrderEnabledChanged(); void onSpamFilterEnabledChanged(); void onStaticRpcPassEnabledChanged(); void customTokenDataChanged(); diff --git a/src/core/atomicdex/pages/qt.trading.page.cpp b/src/core/atomicdex/pages/qt.trading.page.cpp index e073806637..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" @@ -138,7 +139,91 @@ namespace atomic_dex } void - trading_page::place_buy_order(const QString& base_nota, const QString& base_confs) + 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) { this->set_buy_sell_rpc_busy(true); this->set_buy_sell_last_rpc_data(QJsonObject{{}}); @@ -178,6 +263,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 +367,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 +410,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) { @@ -602,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 { @@ -708,6 +835,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 +1522,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..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) @@ -59,6 +60,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) @@ -106,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}; @@ -115,6 +118,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; @@ -159,8 +163,9 @@ 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 place_setprice_order(const QString& rel_nota = "", const QString& rel_confs = "", const QString& cancel_previous = ""); Q_INVOKABLE void reset_order(); @@ -176,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; @@ -197,6 +204,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; @@ -229,6 +237,7 @@ namespace atomic_dex //! Trading logic void priceChanged(); void volumeChanged(); + void makerModeChanged(); void marketModeChanged(); void maxVolumeChanged(); void tradingErrorChanged(); @@ -238,6 +247,7 @@ namespace atomic_dex void baseAmountChanged(); void relAmountChanged(); void feesChanged(); + void pairTrades24hrChanged(); void pairVolume24hrChanged(); void cexPriceChanged(); void cexPriceReversedChanged(); diff --git a/src/core/atomicdex/pages/qt.wallet.page.cpp b/src/core/atomicdex/pages/qt.wallet.page.cpp index 7613bc8dc2..74056aa5e2 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)) @@ -733,7 +735,7 @@ namespace atomic_dex nlohmann::json json_data = mm2::template_request("withdraw", true); mm2::to_json(json_data, withdraw_req); - SPDLOG_DEBUG("final json: {}", json_data.dump(4)); + batch.push_back(json_data); std::string amount_std = amount.toStdString(); 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(); 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/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()); 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..e14d40283c 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" @@ -49,17 +48,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 +118,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 +135,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; diff --git a/src/core/atomicdex/services/price/global.provider.cpp b/src/core/atomicdex/services/price/global.provider.cpp index 1da473e6a7..74aefc3d1a 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,18 @@ namespace atomic_dex global_price_service::refresh_other_coins_rates( const std::string& quote_id, const std::string& ticker, bool with_update_providers, std::atomic_uint16_t nb_try) { - nb_try += 1; - SPDLOG_INFO("refresh_other_coins_rates - try {}", nb_try.load()); - if (nb_try == 10) + t_float_50 price = safe_float(get_rate_conversion("USD", ticker, true)); + if (price <= 0) { - SPDLOG_WARN("refresh other coins rates max try reached, skipping"); - return; + SPDLOG_ERROR("Price is 0 for ticker: {}", ticker); + this->m_coin_rate_providers[ticker] = "0.00"; } - 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) + else { - 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); + t_float_50 rate = 1 / price; + this->m_coin_rate_providers[ticker] = rate.str(); + } + } global_price_service::global_price_service(entt::registry& registry, ag::ecs::system_manager& system_manager, atomic_dex::cfg& cfg) : @@ -189,14 +143,14 @@ namespace atomic_dex { if (fiat == utils::retrieve_main_ticker(ticker_in)) { - return "1"; + return "1.00"; } std::string ticker = utils::retrieve_main_ticker(ticker_in); try { //! FIXME: fix zatJum crash report, frontend QML try to retrieve price before program is even launched if (ticker.empty()) - return "0"; + return "0.00"; auto& provider = m_system_manager.get_system(); std::string current_price = provider.get_rate_conversion(ticker); @@ -231,7 +185,7 @@ namespace atomic_dex { if (current_price_f < 1.0) { - default_precision = 5; + default_precision = 8; } } //! Trick: If there conversion in a fixed representation is 0.00 then use a default precision to 2 without fixed ios flags @@ -312,6 +266,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/services/price/komodo_prices/komodo.prices.provider.cpp b/src/core/atomicdex/services/price/komodo_prices/komodo.prices.provider.cpp index bc3e5d9203..689e12b54c 100644 --- a/src/core/atomicdex/services/price/komodo_prices/komodo.prices.provider.cpp +++ b/src/core/atomicdex/services/price/komodo_prices/komodo.prices.provider.cpp @@ -90,7 +90,7 @@ namespace atomic_dex const auto now = std::chrono::high_resolution_clock::now(); const auto s = std::chrono::duration_cast(now - m_clock); - if (s >= 30s) + if (s >= 45s) { process_update(); m_clock = std::chrono::high_resolution_clock::now(); diff --git a/src/core/atomicdex/services/price/orderbook.scanner.service.cpp b/src/core/atomicdex/services/price/orderbook.scanner.service.cpp index 76c08a5209..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(); } @@ -110,7 +110,7 @@ namespace atomic_dex const auto now = std::chrono::high_resolution_clock::now(); const auto s = std::chrono::duration_cast(now - m_update_clock); - if (s >= 30s) + if (s >= 45s) { SPDLOG_DEBUG("<<<<<<<<<<< orderbook_scanner_service update loop after 30 seconds >>>>>>>>>>>>>"); process_best_orders(); diff --git a/src/core/atomicdex/services/update/zcash.params.service.cpp b/src/core/atomicdex/services/update/zcash.params.service.cpp index af8b1f5d29..ee04bd523d 100644 --- a/src/core/atomicdex/services/update/zcash.params.service.cpp +++ b/src/core/atomicdex/services/update/zcash.params.service.cpp @@ -45,7 +45,7 @@ namespace atomic_dex const auto now = std::chrono::high_resolution_clock::now(); const auto s = std::chrono::duration_cast(now - m_update_clock); - if (s >= 1s) + if (s >= 15s) { // TODO: We could use this for an ETA } 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 diff --git a/src/core/atomicdex/version/version.hpp b/src/core/atomicdex/version/version.hpp index a3126acaa9..55dd6fcdd0 100644 --- a/src/core/atomicdex/version/version.hpp +++ b/src/core/atomicdex/version/version.hpp @@ -21,24 +21,24 @@ namespace atomic_dex constexpr const char* get_version() { - return "0.7.0-beta"; + return "0.7.2-beta"; } constexpr int get_num_version() noexcept { - return 70; + return 72; } constexpr const char* get_raw_version() { - return "0.7.0"; + return "0.7.2"; } constexpr const char* get_precedent_raw_version() { - return "0.6.1"; + return "0.7.1"; } } // namespace atomic_dex diff --git a/vcpkg.json b/vcpkg.json index a8b3291ae0..78278f8556 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "firodex-wallet", - "version-string": "0.7.0", + "version-string": "0.7.2", "dependencies": [ "entt", "boost-multiprecision",