mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 14:11:09 +00:00
fix(liquidity): keep active-pool probes non-submittable
This commit is contained in:
@@ -101,6 +101,8 @@ AmmActionCard {
|
||||
readonly property bool lpDestinationRequired: root.quotePayload.status === "ok"
|
||||
&& root.quotePayload.lpDestinationRequired === true
|
||||
&& root.onlyLpDestinationBlocks()
|
||||
readonly property bool hasActivePoolDepositInput: root.amountA.length > 0
|
||||
&& root.amountB.length > 0
|
||||
readonly property bool canConfirm: root.quotePayload.schema === "new-position.v2"
|
||||
&& root.quotePayload.status === "ok"
|
||||
&& (root.quotePayload.canSubmit === true
|
||||
@@ -113,6 +115,7 @@ AmmActionCard {
|
||||
&& !root.submitting
|
||||
&& !root.poolCreationPending
|
||||
&& root.walletCanSubmit
|
||||
&& (!root.activePool || root.hasActivePoolDepositInput)
|
||||
|
||||
signal quoteRequested(bool immediate, var quoteRequest)
|
||||
signal confirmationRequested(var snapshot)
|
||||
@@ -1174,7 +1177,13 @@ AmmActionCard {
|
||||
root.localErrors = []
|
||||
return
|
||||
}
|
||||
root.quoteRequested(immediate, root.buildQuoteRequest())
|
||||
var built = root.buildQuoteRequest()
|
||||
built.poolDiscoveryProbe = root.confirmedPoolStatus.length === 0
|
||||
&& !root.activePool
|
||||
&& !root.missingPool
|
||||
&& root.amountA.length === 0
|
||||
&& root.amountB.length === 0
|
||||
root.quoteRequested(immediate, built)
|
||||
}
|
||||
|
||||
function probeRaw(token, decimals) {
|
||||
|
||||
@@ -194,8 +194,18 @@ QtObject {
|
||||
if (requestId !== root.activeQuoteRequestId)
|
||||
return
|
||||
root.quoteLoading = false
|
||||
root.quoteStale = false
|
||||
root.quoteErrorCode = ""
|
||||
const isActivePoolDiscovery = root.pendingQuoteRequest.poolDiscoveryProbe === true
|
||||
&& result.schema === "new-position.v2"
|
||||
&& result.status === "ok"
|
||||
&& result.poolStatus === "active_pool"
|
||||
if (isActivePoolDiscovery) {
|
||||
root.newPositionQuote = ({})
|
||||
root.quoteStale = true
|
||||
root.poolActivated(result)
|
||||
return
|
||||
}
|
||||
root.quoteStale = false
|
||||
root.newPositionQuote = result.schema === "new-position.v2"
|
||||
? result : root.quoteError("unsupported_schema")
|
||||
if (root.pendingConfirmationSnapshot) {
|
||||
|
||||
@@ -416,4 +416,55 @@ TestCase {
|
||||
compare(page.flow.newPositionQuote.poolStatus, "missing_pool")
|
||||
verify(page.flow.quoteStale)
|
||||
}
|
||||
|
||||
function test_activePoolDiscoveryDoesNotExposeProbeAsSubmittableQuote() {
|
||||
var tokenA = "22222222222222222222222222222222"
|
||||
var tokenB = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
|
||||
var page = createTemporaryObject(pageComponent, testCase)
|
||||
verify(page)
|
||||
var activated = null
|
||||
function captureActivation(quote) {
|
||||
activated = quote
|
||||
}
|
||||
page.flow.poolActivated.connect(captureActivation)
|
||||
page.flow.pendingQuoteRequest = {
|
||||
"ok": true,
|
||||
"poolDiscoveryProbe": true,
|
||||
"request": {
|
||||
"tokenAId": tokenA,
|
||||
"tokenBId": tokenB
|
||||
}
|
||||
}
|
||||
page.flow.activeQuoteRequestId = 7
|
||||
page.flow.quoteLoading = true
|
||||
page.flow.quoteStale = false
|
||||
page.flow.newPositionQuote = {
|
||||
"schema": "new-position.v2",
|
||||
"status": "ok",
|
||||
"canSubmit": true,
|
||||
"quoteHash": "sha256:old"
|
||||
}
|
||||
|
||||
page.flow.acceptQuoteResult({
|
||||
"schema": "new-position.v2",
|
||||
"status": "ok",
|
||||
"canSubmit": true,
|
||||
"tokenAId": tokenA,
|
||||
"tokenBId": tokenB,
|
||||
"poolStatus": "active_pool",
|
||||
"reserveARaw": "90000000000",
|
||||
"reserveBRaw": "90000000000",
|
||||
"actualAmountARaw": "90000000000",
|
||||
"actualAmountBRaw": "90000000000",
|
||||
"expectedLpRaw": "90000000000",
|
||||
"quoteHash": "sha256:probe",
|
||||
"requestId": 7
|
||||
})
|
||||
|
||||
compare(activated.poolStatus, "active_pool")
|
||||
compare(page.flow.quoteLoading, false)
|
||||
verify(page.flow.quoteStale)
|
||||
compare(Object.keys(page.flow.newPositionQuote).length, 0)
|
||||
page.flow.poolActivated.disconnect(captureActivation)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,6 +455,17 @@ TestCase {
|
||||
compare(form.amountB, "")
|
||||
compare(form.minimumAmountARaw, "")
|
||||
compare(form.minimumAmountBRaw, "")
|
||||
form.flowState = flowState({
|
||||
"schema": "new-position.v2",
|
||||
"status": "ok",
|
||||
"canSubmit": true,
|
||||
"tokenAId": tokenHigh,
|
||||
"tokenBId": tokenLow,
|
||||
"poolStatus": "active_pool",
|
||||
"quoteHash": "sha256:probe"
|
||||
})
|
||||
wait(0)
|
||||
compare(form.canConfirm, false)
|
||||
quoteRequestedSpy.target = form
|
||||
quoteRequestedSpy.clear()
|
||||
form.requestQuote(true)
|
||||
|
||||
Reference in New Issue
Block a user