From 903595db00443bc9484be2ac180d27be33270709 Mon Sep 17 00:00:00 2001 From: Evgeniia Vakarina <27793901+EvgeniiaVak@users.noreply.github.com> Date: Tue, 12 Dec 2023 16:45:45 +0400 Subject: [PATCH 1/2] fix price error message for amount validation --- src/app/state/orderInputSlice.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/state/orderInputSlice.ts b/src/app/state/orderInputSlice.ts index 8b519778..0d902fdf 100644 --- a/src/app/state/orderInputSlice.ts +++ b/src/app/state/orderInputSlice.ts @@ -21,6 +21,7 @@ export enum OrderTab { export enum ErrorMessage { UNSPECIFIED_PRICE = "Price must be specified", NONZERO_PRICE = "Price must be greater than 0", + NONZERO_AMOUNT = "Amount must be greater than 0", HIGH_PRICE = "Price is significantly higher than best sell", LOW_PRICE = "Price is significantly lower than best buy", EXCESSIVE_DECIMALS = "Too many decimal places", @@ -628,7 +629,7 @@ function _validateAmount(amount: number | ""): ValidationResult { */ if (amount <= 0) { valid = false; - message = ErrorMessage.NONZERO_PRICE; + message = ErrorMessage.NONZERO_AMOUNT; } return { valid, message }; From b9a34e5406792316597c6ce7ad683ebc06e83874 Mon Sep 17 00:00:00 2001 From: Evgeniia Vakarina <27793901+EvgeniiaVak@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:34:42 +0400 Subject: [PATCH 2/2] fix decimals not displayed in orderbook --- src/app/components/OrderBook.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/components/OrderBook.tsx b/src/app/components/OrderBook.tsx index 68183cea..6029f678 100644 --- a/src/app/components/OrderBook.tsx +++ b/src/app/components/OrderBook.tsx @@ -5,7 +5,13 @@ import * as utils from "../utils"; import { OrderBookRowProps, orderBookSlice } from "../state/orderBookSlice"; import { useAppDispatch, useAppSelector } from "../hooks"; -const N_DIGITS = 8; +// For all intents, we can round all numbers to 8 decimals for Dexter. +// Alphadex will not accept any numbers with more than 8 decimals +// and it is doubtful whether people are that interested in numbers with more decimals. +// https://discord.com/channels/1125689933735145503/1125689934251032584/1181882491464843314 + +// 10 = for possible 8 decimals in smaller than 1 numbers + 1 for the decimal point + 1 for the leading 0 +const CHARACTERS_TO_DISPLAY = 10; function OrderBookRow(props: OrderBookRowProps) { const { barColor, orderCount, price, size, total, maxTotal } = props; @@ -17,10 +23,9 @@ function OrderBookRow(props: OrderBookRowProps) { typeof total !== "undefined" && typeof maxTotal !== "undefined" ) { - const charactersToDisplay = 6; - const priceString = utils.displayNumber(price, charactersToDisplay); - const sizeString = utils.displayNumber(size, charactersToDisplay); - const totalString = utils.displayNumber(total, charactersToDisplay); + const priceString = utils.displayNumber(price, CHARACTERS_TO_DISPLAY); + const sizeString = utils.displayNumber(size, CHARACTERS_TO_DISPLAY); + const totalString = utils.displayNumber(total, CHARACTERS_TO_DISPLAY); const barWidth = `${(total / maxTotal) * 100}%`; const barStyle = { @@ -72,12 +77,12 @@ function CurrentPriceRow() { if (orderBook.spreadPercent !== null && orderBook.spread !== null) { const spread = utils.displayPositiveNumber( orderBook.spread, - N_DIGITS, + CHARACTERS_TO_DISPLAY, token2MaxDecimals ); const spreadPercent = utils.displayPositiveNumber( orderBook.spreadPercent, - N_DIGITS, + CHARACTERS_TO_DISPLAY, 2 );