Skip to content

Commit

Permalink
Merge pull request #1934 from KomodoPlatform/extra_warning
Browse files Browse the repository at this point in the history
warning when high margin
  • Loading branch information
tonymorony committed Aug 24, 2022
2 parents e929ffc + 7a75829 commit dedcde5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
9 changes: 9 additions & 0 deletions atomic_defi_design/Dex/Constants/General.qml
Expand Up @@ -577,6 +577,15 @@ QtObject {
return tx_fee + "\n" + trading_fee +"<br>"+minimum_amount
}

function is_swap_safe(checkbox)
{
if (checkbox.checked == true || checkbox.visible == false)
{
return (!API.app.trading_pg.buy_sell_rpc_busy && API.app.trading_pg.last_trading_error == TradingError.None)
}
return false
}

function validateWallet(wallet_name) {
if (wallet_name.length >= 25) return "Wallet name must 25 chars or less"
return checkIfWalletExists(wallet_name)
Expand Down
42 changes: 38 additions & 4 deletions atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml
Expand Up @@ -11,6 +11,7 @@ import "Orders/"
import App 1.0
import Dex.Themes 1.0 as Dex


MultipageModal
{
id: root
Expand All @@ -24,9 +25,9 @@ MultipageModal
titleText: qsTr("Confirm Exchange Details")
title.font.pixelSize: Style.textSize2
titleAlignment: Qt.AlignHCenter
titleTopMargin: 10
topMarginAfterTitle: 0
flickMax: window.height - 450
titleTopMargin: 0
topMarginAfterTitle: 10
flickMax: window.height - 480

header: [
RowLayout
Expand Down Expand Up @@ -71,6 +72,39 @@ MultipageModal
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter

// Large margin Warning
FloatingBackground
{
Layout.alignment: Qt.AlignCenter
width: 425
height: 30
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: 20
boxHeight: 20
labelWidth: 400
label.wrapMode: Label.NoWrap
text: qsTr("Trade price is more than 50% different to CEX! Confirm?")
}

Item { width: 3 }
}
}

DefaultText
{
Layout.alignment: Qt.AlignHCenter
Expand Down Expand Up @@ -368,7 +402,7 @@ MultipageModal
leftPadding: 45
rightPadding: 45
radius: 10
enabled: !buy_sell_rpc_busy && last_trading_error === TradingError.None
enabled: General.is_swap_safe(allow_bad_trade)
onClicked:
{
trade({ enable_custom_config: enable_custom_config.checked,
Expand Down

0 comments on commit dedcde5

Please sign in to comment.