Skip to content

Commit

Permalink
fix: currency input refactors decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
galvin96 committed Dec 30, 2024
1 parent c70a748 commit 882ddc1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/pages/DexV2/Lock/components/CurrencyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ export default function CurrencyInputPanel({
const { account } = useActiveWeb3React()
const selectedCurrencyBalance = useCurrencyBalance(account ?? undefined, currency ?? undefined)
const theme = useTheme()

const decimals = (currency?.tokenInfo?.decimals ?? 18) > 4 ? 4 : currency?.tokenInfo?.decimals ?? 18

const decimals = currency?.tokenInfo?.decimals || 18
const onChangeInput = (val: string) => {
const floatingPart = val.split('.')[1]
const inputDecimals = currency?.decimals || (currency as any)?.tokenInfo?.decimals || 2
if (floatingPart && currency && inputDecimals < floatingPart.length) return
const inputDecimals = decimals
if (floatingPart && inputDecimals < floatingPart.length) return
onUserInput(val)
}

Expand Down

0 comments on commit 882ddc1

Please sign in to comment.