From 3f4b9467e6be6a91bc60f6198d611a1ddcf570db Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Sat, 18 Jul 2026 04:13:51 -0300 Subject: [PATCH] fix(liquidity): reconcile holdings before quotes --- .../components/liquidity/NewPositionForm.qml | 2 +- apps/amm/tests/qml/tst_NewPositionForm.qml | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/amm/qml/components/liquidity/NewPositionForm.qml b/apps/amm/qml/components/liquidity/NewPositionForm.qml index 8282849..0c81dbe 100644 --- a/apps/amm/qml/components/liquidity/NewPositionForm.qml +++ b/apps/amm/qml/components/liquidity/NewPositionForm.qml @@ -128,11 +128,11 @@ AmmActionCard { Component.onCompleted: Qt.callLater(root.reconcileSelection) onNewPositionContextChanged: Qt.callLater(root.applyContextChange) function applyContextChange() { + root.reconcileHoldings() if (root.resolvingToken) root.finishTokenResolution() else root.reconcileSelection() - root.reconcileHoldings() } onQuotePayloadChanged: { if (root.quoteStale) diff --git a/apps/amm/tests/qml/tst_NewPositionForm.qml b/apps/amm/tests/qml/tst_NewPositionForm.qml index 15b77fa..530d8b9 100644 --- a/apps/amm/tests/qml/tst_NewPositionForm.qml +++ b/apps/amm/tests/qml/tst_NewPositionForm.qml @@ -183,6 +183,27 @@ TestCase { "44444444444444444444444444444444") } + function test_contextRefreshSelectsSingleHoldingsBeforeQuote() { + var form = createForm() + form.selectedHoldingAId = "" + form.selectedHoldingBId = "" + quoteRequestedSpy.target = form + quoteRequestedSpy.clear() + + form.newPositionContext = readyContext() + + tryCompare(quoteRequestedSpy, "count", 1) + compare(form.selectedHoldingAId, + "44444444444444444444444444444444") + compare(form.selectedHoldingBId, + "55555555555555555555555555555555") + verify(quoteRequestedSpy.signalArguments[0][1].ok) + compare(quoteRequestedSpy.signalArguments[0][1].request.holdingAId, + "55555555555555555555555555555555") + compare(quoteRequestedSpy.signalArguments[0][1].request.holdingBId, + "44444444444444444444444444444444") + } + function test_displayOrderMapsToCanonicalRequestAfterSwap() { var form = createForm() var built = form.buildQuoteRequest()