@@ -11,7 +11,7 @@ import { TradingLimits } from '../swaps/SwapClient';
11
11
import Swaps from '../swaps/Swaps' ;
12
12
import { ResolveRequest , SwapFailure , SwapSuccess } from '../swaps/types' ;
13
13
import { parseUri , toUri , UriParts } from '../utils/uriUtils' ;
14
- import { sortOrders , toEip55Address } from '../utils/utils' ;
14
+ import { checkDecimalPlaces , sortOrders , toEip55Address } from '../utils/utils' ;
15
15
import commitHash from '../Version' ;
16
16
import errors from './errors' ;
17
17
@@ -58,6 +58,9 @@ const argChecks = {
58
58
POSITIVE_AMOUNT : ( { amount } : { amount : number } ) => { if ( amount <= 0 ) throw errors . INVALID_ARGUMENT ( 'amount must be greater than 0' ) ; } ,
59
59
POSITIVE_QUANTITY : ( { quantity } : { quantity : number } ) => { if ( quantity <= 0 ) throw errors . INVALID_ARGUMENT ( 'quantity must be greater than 0' ) ; } ,
60
60
PRICE_NON_NEGATIVE : ( { price } : { price : number } ) => { if ( price < 0 ) throw errors . INVALID_ARGUMENT ( 'price cannot be negative' ) ; } ,
61
+ PRICE_MAX_DECIMAL_PLACES : ( { price } : { price : number } ) => {
62
+ if ( checkDecimalPlaces ( price ) ) throw errors . INVALID_ARGUMENT ( 'price cannot have more than 12 decimal places' ) ;
63
+ } ,
61
64
VALID_CURRENCY : ( { currency } : { currency : string } ) => {
62
65
if ( currency . length < 2 || currency . length > 5 || ! currency . match ( / ^ [ A - Z 0 - 9 ] + $ / ) ) {
63
66
throw errors . INVALID_ARGUMENT ( 'currency must consist of 2 to 5 upper case English letters or numbers' ) ;
@@ -447,6 +450,7 @@ class Service {
447
450
const { pairId, price, quantity, orderId, side, replaceOrderId, immediateOrCancel } = args ;
448
451
argChecks . PRICE_NON_NEGATIVE ( args ) ;
449
452
argChecks . POSITIVE_QUANTITY ( args ) ;
453
+ argChecks . PRICE_MAX_DECIMAL_PLACES ( args ) ;
450
454
argChecks . HAS_PAIR_ID ( args ) ;
451
455
452
456
if ( replaceOrderId ) {
0 commit comments