Skip to content

Commit

Permalink
fix: send funds input amount as fiat (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKheops authored Oct 6, 2023
1 parent 8e7ab29 commit 74b506b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ const FiatInput = () => {

const text = e.target.value ?? ""
const num = Number(text)
const tokenRate = tokenRates?.[currency]

if (token && tokenRates?.usd && text.length && !isNaN(num)) {
if (token && tokenRate && text.length && !isNaN(num)) {
const fiat = parseFloat(text)
const tokens = (fiat / tokenRates.usd).toFixed(Math.ceil(token.decimals / 3))
const tokens = (fiat / tokenRate).toFixed(Math.ceil(token.decimals / 3))
set("amount", tokensToPlanck(tokens, token.decimals))
} else remove("amount")
}, 250),
Expand Down

0 comments on commit 74b506b

Please sign in to comment.