Skip to content

Commit

Permalink
Merge pull request #489 from liquality/feat/liq-876-fee-is-more-than-…
Browse files Browse the repository at this point in the history
…available-balance

feat: do not allow swap in boost if user cannot cover fee
  • Loading branch information
tima-t authored Dec 16, 2021
2 parents 55f52a4 + 23c855b commit 3b87d44
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/views/Swap/Swap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,12 @@ export default {
: BN.max(BN(balance).minus(this.maxFee), 0)
return unitToCurrency(cryptoassets[this.asset], available)
},
canCoverAmmFee () {
if (!this.selectedQuote.bridgeAsset) return true
const balance = this.toAccount?.balances[this.selectedQuote.bridgeAsset]
const toSwapFeeInUnits = currencyToUnit(cryptoassets[this.selectedQuote.bridgeAsset], this.toSwapFee)
return (BN(balance).plus(this.selectedQuote.bridgeAssetAmount)).gt(toSwapFeeInUnits)
},
availableAmount () {
return dpUI(this.available, VALUE_DECIMALS)
},
Expand Down Expand Up @@ -758,6 +764,7 @@ export default {
!this.selectedQuote ||
this.updatingQuotes ||
this.ethRequired ||
!this.canCoverAmmFee ||
this.showNoLiquidityMessage ||
this.amountError ||
BN(this.safeAmount).lte(0)
Expand Down

0 comments on commit 3b87d44

Please sign in to comment.