File tree 3 files changed +9
-0
lines changed
3 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const getGrpcError = (err: any) => {
22
22
case orderErrorCodes . MIN_QUANTITY_VIOLATED :
23
23
case orderErrorCodes . QUANTITY_DOES_NOT_MATCH :
24
24
case swapErrorCodes . REMOTE_IDENTIFIER_MISSING :
25
+ case orderErrorCodes . DUPLICATE_PAIR_CURRENCIES :
25
26
code = status . INVALID_ARGUMENT ;
26
27
break ;
27
28
case orderErrorCodes . PAIR_DOES_NOT_EXIST :
Original file line number Diff line number Diff line change @@ -290,6 +290,9 @@ class OrderBook extends EventEmitter {
290
290
291
291
public addPair = async ( pair : Pair ) => {
292
292
const pairId = derivePairId ( pair ) ;
293
+ if ( pair . baseCurrency . toLowerCase ( ) === pair . quoteCurrency . toLowerCase ( ) ) {
294
+ throw errors . DUPLICATE_PAIR_CURRENCIES ( pair . baseCurrency , pair . quoteCurrency ) ;
295
+ }
293
296
if ( this . pairInstances . has ( pairId ) ) {
294
297
throw errors . PAIR_ALREADY_EXISTS ( pairId ) ;
295
298
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const errorCodes = {
16
16
INSUFFICIENT_OUTBOUND_BALANCE : codesPrefix . concat ( '.12' ) ,
17
17
MIN_QUANTITY_VIOLATED : codesPrefix . concat ( '.13' ) ,
18
18
QUANTITY_ON_HOLD : codesPrefix . concat ( '.15' ) ,
19
+ DUPLICATE_PAIR_CURRENCIES : codesPrefix . concat ( '.16' ) ,
19
20
} ;
20
21
21
22
const errors = {
@@ -75,6 +76,10 @@ const errors = {
75
76
message : `order with local id ${ localId } has a quantity of ${ holdQuantity } satoshis on hold, try again later` ,
76
77
code : errorCodes . QUANTITY_DOES_NOT_MATCH ,
77
78
} ) ,
79
+ DUPLICATE_PAIR_CURRENCIES : ( baseCurrency : string , quoteCurrency : string ) => ( {
80
+ message : `base asset (${ baseCurrency } ) and quote asset (${ quoteCurrency } ) have to be different` ,
81
+ code : errorCodes . DUPLICATE_PAIR_CURRENCIES ,
82
+ } ) ,
78
83
} ;
79
84
80
85
export { errorCodes } ;
You can’t perform that action at this time.
0 commit comments