diff --git a/taker-frontend/src/components/Trade.test.tsx b/taker-frontend/src/components/Trade.test.tsx
new file mode 100644
index 0000000..297178b
--- /dev/null
+++ b/taker-frontend/src/components/Trade.test.tsx
@@ -0,0 +1,9 @@
+import { isEvenlyDivisible } from "./Trade";
+
+it("1200 is evenly divisible by 100.0", () => {
+ expect(isEvenlyDivisible(1200, 100.0)).toBe(true);
+});
+
+it("233.3 is not evenly divisible by 100.0", () => {
+ expect(isEvenlyDivisible(233.3, 100.0)).toBe(false);
+});
diff --git a/taker-frontend/src/components/Trade.tsx b/taker-frontend/src/components/Trade.tsx
index d3c00fa..3900364 100644
--- a/taker-frontend/src/components/Trade.tsx
+++ b/taker-frontend/src/components/Trade.tsx
@@ -112,9 +112,11 @@ export default function Trade({
const quantityTooHigh = maxQuantity < parse(quantity);
const quantityTooLow = minQuantity > parse(quantity);
const quantityGreaterZero = parse(quantity) > 0;
+ const quantityIncrement = 100;
+ const quantityIsEvenlyDivisibleByIncrement = isEvenlyDivisible(parse(quantity), quantityIncrement);
const canSubmit = orderId && !isLongSubmitting && !balanceTooLow
- && !quantityTooHigh && !quantityTooLow && quantityGreaterZero;
+ && !quantityTooHigh && !quantityTooLow && quantityGreaterZero && quantityIsEvenlyDivisibleByIncrement;
let alertBox;
@@ -130,6 +132,12 @@ export default function Trade({
description={"Please deposit more into you wallet."}
/>;
}
+ if (!quantityIsEvenlyDivisibleByIncrement) {
+ alertBox = ;
+ }
if (quantityTooHigh) {
alertBox =
-
+
@@ -276,10 +290,11 @@ interface QuantityProps {
min: number;
max: number;
quantity: string;
+ quantityIncrement: number;
onChange: any;
}
-function Quantity({ min, max, onChange, quantity }: QuantityProps) {
+function Quantity({ min, max, onChange, quantity, quantityIncrement }: QuantityProps) {
return (
Quantity
@@ -289,6 +304,7 @@ function Quantity({ min, max, onChange, quantity }: QuantityProps) {
min={min}
max={max}
default={min}
+ step={quantityIncrement}
onChange={onChange}
value={quantity}
>
@@ -345,3 +361,7 @@ function Margin({ margin }: MarginProps) {
);
}
+
+export function isEvenlyDivisible(numerator: number, divisor: number): boolean {
+ return (numerator % divisor === 0.0);
+}