mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-20 05:50:32 +00:00
fix(amm): reject exact output at pool reserve
This commit is contained in:
parent
a8de6b498c
commit
a3bbcda7c2
@ -86,7 +86,7 @@ Rectangle {
|
|||||||
readonly property bool tokensSelected: sellToken !== null && buyToken !== null
|
readonly property bool tokensSelected: sellToken !== null && buyToken !== null
|
||||||
readonly property bool sameTokenSelected: isSameToken(sellToken, buyToken)
|
readonly property bool sameTokenSelected: isSameToken(sellToken, buyToken)
|
||||||
readonly property bool insufficientBalance: hasAmount && sellToken !== null && sellBalanceRequirement > (sellToken.balance || 0)
|
readonly property bool insufficientBalance: hasAmount && sellToken !== null && sellBalanceRequirement > (sellToken.balance || 0)
|
||||||
readonly property bool insufficientLiquidity: hasAmount && buyToken !== null && parsedBuyAmount > (buyToken.reserve || 0)
|
readonly property bool insufficientLiquidity: hasAmount && buyToken !== null && parsedBuyAmount >= (buyToken.reserve || 0)
|
||||||
readonly property bool canSubmit: tokensSelected && !sameTokenSelected && hasAmount && parsedSellAmount > 0 && parsedBuyAmount > 0 && !insufficientBalance && !insufficientLiquidity
|
readonly property bool canSubmit: tokensSelected && !sameTokenSelected && hasAmount && parsedSellAmount > 0 && parsedBuyAmount > 0 && !insufficientBalance && !insufficientLiquidity
|
||||||
|
|
||||||
readonly property string submitButtonText: {
|
readonly property string submitButtonText: {
|
||||||
|
|||||||
@ -127,6 +127,23 @@ Item {
|
|||||||
compare(card.submitButtonText, "Insufficient balance")
|
compare(card.submitButtonText, "Insufficient balance")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_exactOutputCannotConsumeEntireReserve() {
|
||||||
|
const page = createTemporaryObject(pageComponent, root)
|
||||||
|
verify(page)
|
||||||
|
|
||||||
|
const card = findChild(page, "swapCard")
|
||||||
|
verify(card)
|
||||||
|
card.setToken("sell", page.tokens[0])
|
||||||
|
card.setToken("buy", page.tokens[1])
|
||||||
|
card.buyInput = String(card.buyToken.reserve)
|
||||||
|
card.editingSide = "buy"
|
||||||
|
|
||||||
|
compare(card.parsedBuyAmount, card.buyToken.reserve)
|
||||||
|
verify(card.insufficientLiquidity)
|
||||||
|
verify(!card.canSubmit)
|
||||||
|
compare(card.submitButtonText, "Insufficient liquidity")
|
||||||
|
}
|
||||||
|
|
||||||
function test_reselectingOppositeTokenSwapsPair() {
|
function test_reselectingOppositeTokenSwapsPair() {
|
||||||
const page = createTemporaryObject(pageComponent, root)
|
const page = createTemporaryObject(pageComponent, root)
|
||||||
verify(page)
|
verify(page)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user