diff --git a/ts/client/src/accounts/bookSide.ts b/ts/client/src/accounts/bookSide.ts index b3e2c125c..4f8ef7241 100644 --- a/ts/client/src/accounts/bookSide.ts +++ b/ts/client/src/accounts/bookSide.ts @@ -65,7 +65,7 @@ export class BookSide { return; } const stack = [this.rootFixed.maybeNode]; - const [left, right] = this.side === SideUtils.Bid ? [1, 0] : [0, 1]; + const [left, right] = this.side.bid ? [1, 0] : [0, 1]; while (stack.length > 0) { const index = stack.pop()!; @@ -94,7 +94,7 @@ export class BookSide { return; } const stack = [this.rootOraclePegged.maybeNode]; - const [left, right] = this.side === SideUtils.Bid ? [1, 0] : [0, 1]; + const [left, right] = this.side.bid ? [1, 0] : [0, 1]; while (stack.length > 0) { const index = stack.pop()!; @@ -122,7 +122,7 @@ export class BookSide { public compareOrders(a: Order, b: Order): boolean { return a.priceLots.eq(b.priceLots) ? a.seqNum.lt(b.seqNum) // if prices are equal prefer orders in the order they are placed - : this.side === SideUtils.Bid // else compare the actual prices + : this.side.bid // else compare the actual prices ? a.priceLots.gt(b.priceLots) : b.priceLots.gt(a.priceLots); } diff --git a/ts/client/src/accounts/openOrders.ts b/ts/client/src/accounts/openOrders.ts index 3b2816c6d..fca9412bd 100644 --- a/ts/client/src/accounts/openOrders.ts +++ b/ts/client/src/accounts/openOrders.ts @@ -160,7 +160,7 @@ export class OpenOrders { public async placeOrder(order: OrderToPlace): Promise { // derive token account const mint = - order.side === SideUtils.Bid + order.side.bid ? this.market.account.quoteMint : this.market.account.baseMint; const userTokenAccount = await getAssociatedTokenAddress( @@ -172,11 +172,11 @@ export class OpenOrders { const remainingAccounts = new Set(); const bookSide = - order.side === SideUtils.Bid ? this.market.asks : this.market.bids; + order.side.bid ? this.market.asks : this.market.bids; if ( bookSide && - order.orderType !== PlaceOrderTypeUtils.PostOnly && - order.orderType !== PlaceOrderTypeUtils.PostOnlySlide + !order.orderType?.postOnly && + !order.orderType?.postOnlySlide ) { for (const order of bookSide.items()) { remainingAccounts.add(order.leafNode.owner.toBase58()); @@ -411,11 +411,11 @@ export class OpenOrders { ? new BN(order.quoteLimit) : I64_MAX_BN; const clientOrderId = new BN(order.clientOrderId || Date.now()); - const orderType = order.orderType || PlaceOrderTypeUtils.Limit; - const expiryTimestamp = new BN(order.expiryTimestamp || 0); + const orderType = order.orderType ?? PlaceOrderTypeUtils.Limit; + const expiryTimestamp = new BN(order.expiryTimestamp ?? 0); const selfTradeBehavior = - order.selfTradeBehavior || SelfTradeBehaviorUtils.DecrementTake; - const limit = order.matchLoopLimit || 16; + order.selfTradeBehavior ?? SelfTradeBehaviorUtils.DecrementTake; + const limit = order.matchLoopLimit ?? 16; const args = { side: order.side, diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 3a6668a38..a70e4dfbb 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -567,7 +567,7 @@ export class OpenBookV2Client { userBaseAccount, userQuoteAccount, marketBaseVault: market.marketBaseVault, - marketQuoteVault: market.marketBaseVault, + marketQuoteVault: market.marketQuoteVault, tokenProgram: TOKEN_PROGRAM_ID, }) .instruction(); @@ -589,7 +589,7 @@ export class OpenBookV2Client { openOrdersDelegate?: Keypair, ): Promise<[TransactionInstruction, Signer[]]> { const marketVault = - args.side === SideUtils.Bid + args.side.bid ? market.marketQuoteVault : market.marketBaseVault; const accountsMeta: AccountMeta[] = remainingAccounts.map((remaining) => ({ @@ -638,7 +638,7 @@ export class OpenBookV2Client { openOrdersDelegate?: Keypair, ): Promise<[TransactionInstruction, Signer[]]> { const marketVault = - args.side === SideUtils.Bid + args.side.bid ? market.marketQuoteVault : market.marketBaseVault; const accountsMeta: AccountMeta[] = remainingAccounts.map((remaining) => ({ diff --git a/ts/client/src/structs/order.ts b/ts/client/src/structs/order.ts index 491e0aca4..459a3e3d0 100644 --- a/ts/client/src/structs/order.ts +++ b/ts/client/src/structs/order.ts @@ -13,7 +13,7 @@ export class Order { public isOraclePegged = false, ) { this.seqNum = - this.side === SideUtils.Bid + this.side.bid ? U64_MAX_BN.sub(this.leafNode.key.maskn(64)) : this.leafNode.key.maskn(64); const priceData = this.leafNode.key.ushrn(64); @@ -39,7 +39,7 @@ export class Order { } public toPrettyString(): string { - return `side:${this.side === SideUtils.Bid ? 'bid' : 'ask'} price:${ + return `side:${this.side.bid ? 'bid' : 'ask'} price:${ this.price } size:${this.size} seqNum:${this.seqNum.toString()} expired:${ this.isExpired