Skip to content

Commit

Permalink
fix: set quote token amount to zero when source token is empty in swa…
Browse files Browse the repository at this point in the history
…p UI
  • Loading branch information
Nithishvb committed Jan 27, 2025
1 parent a6f0943 commit 95e4239
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-flowers-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@reown/appkit-core': patch
---

Set Quote Token Amount to Zero When Source Token is Empty
4 changes: 4 additions & 0 deletions packages/core/src/controllers/SwapController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ export const SwapController = {
const toToken = state.toToken
const haveSourceTokenAmount = NumberUtil.bigNumber(state.sourceTokenAmount).isGreaterThan(0)

if (!haveSourceTokenAmount) {
this.setToTokenAmount('')
}

if (!toToken || !sourceToken || state.loadingPrices || !haveSourceTokenAmount) {
return
}
Expand Down

0 comments on commit 95e4239

Please sign in to comment.