Throw error if price or size is too small
This commit is contained in:
parent
9223575e6f
commit
7848262c4d
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@project-serum/serum",
|
||||
"version": "0.4.1",
|
||||
"version": "0.4.2",
|
||||
"description": "Library for interacting with the serum dex",
|
||||
"license": "MIT",
|
||||
"repository": "project-serum/serum-js",
|
||||
|
|
|
@ -210,6 +210,12 @@ export class Market {
|
|||
} else {
|
||||
openOrdersAddress = openOrdersAccounts[0].address;
|
||||
}
|
||||
if (this.baseSizeNumberToLots(size).lte(new BN(0))) {
|
||||
throw new Error('size too small');
|
||||
}
|
||||
if (this.priceNumberToLots(price).lte(new BN(0))) {
|
||||
throw new Error('invalid price');
|
||||
}
|
||||
transaction.add(
|
||||
DexInstructions.newOrder({
|
||||
market: this.address,
|
||||
|
@ -372,6 +378,14 @@ export class Market {
|
|||
return native.div(this._decoded.quoteLotSize);
|
||||
}
|
||||
|
||||
get minOrderSize() {
|
||||
return this.baseSizeLotsToNumber(new BN(1));
|
||||
}
|
||||
|
||||
get tickSize() {
|
||||
return this.priceLotsToNumber(new BN(1));
|
||||
}
|
||||
|
||||
async matchOrders(connection: Connection, feePayer: Account, limit: number) {
|
||||
const tx = new Transaction();
|
||||
tx.add(
|
||||
|
|
Loading…
Reference in New Issue