Skip to content

Commit

Permalink
Merge pull request #48 from Levana-Protocol/perp-4131/sell-form-bug
Browse files Browse the repository at this point in the history
PERP-4131 | Fix not being able to change shares field after clicking on "max"
  • Loading branch information
lvn-rusty-dragon authored Sep 30, 2024
2 parents f25967c + f8ac04b commit c0be27e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ const SharesAmountField = (props: SharesAmountFieldProps) => {
*/
const onChange = useCallback(
(newAmount: string) => {
const regex = VALID_DECIMAL_REGEX(3)
if (balance) {
const regex = VALID_DECIMAL_REGEX(balance?.maxDecimalPlaces)

if (balance && matchesRegex(newAmount, regex)) {
setFormValue(newAmount === "." ? "0." : newAmount)
if (matchesRegex(newAmount, regex)) {
setFormValue(newAmount === "." ? "0." : newAmount)
}
}
},
[balance, setFormValue],
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ abstract class Asset {
}

toFullPrecision(withSuffix: boolean): string {
return `${this.getValue().toFormat(this.exponent)}${withSuffix ? ` ${this.symbol}` : ""}`
return `${this.getValue().toFormat(this.maxDecimalPlaces)}${withSuffix ? ` ${this.symbol}` : ""}`
}

getValue(): BigNumber {
Expand Down

0 comments on commit c0be27e

Please sign in to comment.