Skip to content

Commit

Permalink
Merge pull request #2420 from KomodoPlatform/add/order-info
Browse files Browse the repository at this point in the history
Add/order info
  • Loading branch information
smk762 authored Apr 6, 2024
2 parents 2bb35a2 + b52849a commit fa1821f
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 4 deletions.
10 changes: 10 additions & 0 deletions atomic_defi_design/Dex/Components/PairItemBadge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions atomic_defi_design/Dex/Constants/DexTypo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 : ""
Expand Down Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion src/core/atomicdex/api/mm2/mm2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ namespace atomic_dex::mm2
.is_swap = false,
.is_cancellable = value.at("cancellable").get<bool>(),
.is_recoverable = false,
.min_volume = is_maker ? QString::fromStdString(value.at("min_base_vol").get<std::string>()) : std::optional<QString>(std::nullopt),
.min_volume = is_maker ? QString::fromStdString(value.at("min_base_vol").get<std::string>()) : "",
.max_volume = is_maker ? QString::fromStdString(value.at("max_base_vol").get<std::string>()) : "",
.conf_settings = conf_settings};
if (action.empty() && contents.order_type == "maker")
{
Expand Down
2 changes: 0 additions & 2 deletions src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/core/atomicdex/data/dex/qt.orders.data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ namespace atomic_dex::mm2
bool is_swap_active{false};

//! Only available for maker order
std::optional<QString> min_volume{std::nullopt};
QString min_volume;
QString max_volume;
std::optional<nlohmann::json> conf_settings{std::nullopt};
};
} // namespace atomic_dex::mm2
Expand Down
12 changes: 12 additions & 0 deletions src/core/atomicdex/models/qt.orders.model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"},
Expand Down
2 changes: 2 additions & 0 deletions src/core/atomicdex/models/qt.orders.model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace atomic_dex
RelCoinAmountRole,
RelCoinAmountCurrentCurrencyRole,
OrderTypeRole,
MinVolumeRole,
MaxVolumeRole,
IsMakerRole,
HumanDateRole,
UnixTimestampRole,
Expand Down
4 changes: 4 additions & 0 deletions src/core/atomicdex/models/qt.orders.proxy.model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions src/core/atomicdex/services/price/global.provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ namespace atomic_dex
{
try
{
if (amount == "" || ticker == "" || currency == "")
{
return "0.00";
}

auto& mm2_instance = m_system_manager.get_system<mm2_service>();

const auto ticker_infos = mm2_instance.get_coin_info(ticker);
Expand Down
4 changes: 4 additions & 0 deletions src/core/atomicdex/utilities/safe.float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ 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;
}
Expand Down

0 comments on commit fa1821f

Please sign in to comment.