Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning when high margin #1934

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions atomic_defi_design/Dex/Constants/General.qml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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