From d96a1dbc27a3ea28b1e1167d065ab38941ee8c5b Mon Sep 17 00:00:00 2001 From: Ludovit Scholtz Date: Fri, 1 Nov 2024 08:43:34 +0100 Subject: [PATCH] improve swap quotes --- src/pages/Swap.vue | 64 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/src/pages/Swap.vue b/src/pages/Swap.vue index 2ff7aeb..151a245 100644 --- a/src/pages/Swap.vue +++ b/src/pages/Swap.vue @@ -196,7 +196,17 @@ /> {{ $t("swap.execute_button_deflex") }} - +
Quote:
+
+ {{ + this.$filters.formatCurrency( + Number(this.deflexQuotes.quote), + "", + this.toAssetDecimals + ) + }} +
+
Price:
{{ this.$filters.formatCurrency( @@ -208,6 +218,19 @@ ) }}
+
+ {{ + this.$filters.formatCurrency( + 10 ** 6 / + ((10 ** 6 * Number(this.deflexQuotes.quote)) / + 10 ** this.toAssetDecimals / + this.payamount / + 10 ** 6), + this.pairReversed, + 6 + ) + }} +
@@ -403,6 +450,9 @@ export default { pair() { return `${this.fromAssetUnit}/${this.toAssetUnit}`; }, + pairReversed() { + return `${this.toAssetUnit}/${this.fromAssetUnit}`; + }, isFolksQuoteBetter() { if (!this.folksQuote) { return false; @@ -459,6 +509,7 @@ export default { }; } this.payamount = 0; + localStorage.setItem("last-swap-from-asset", this.asset); }, async toAsset() { this.deflexTxs = { groupMetadata: [] }; @@ -475,6 +526,7 @@ export default { decimals: 6, }; } + localStorage.setItem("last-swap-to-asset", this.toAsset); }, account() { this.deflexTxs = { groupMetadata: [] }; @@ -501,9 +553,19 @@ export default { this.payamount = 1; if (this.$route.params.fromAsset) { this.asset = this.$route.params.fromAsset; + } else { + const asset = localStorage.getItem("last-swap-from-asset"); + if (asset) { + this.asset = Number(asset); + } } if (this.$route.params.toAsset) { this.toAsset = this.$route.params.toAsset; + } else { + const asset = localStorage.getItem("last-swap-to-asset"); + if (asset) { + this.toAsset = Number(asset); + } } }, methods: {