diff --git a/idl/openbook_v2.json b/idl/openbook_v2.json index 43cdbff59..e93e8bc2d 100644 --- a/idl/openbook_v2.json +++ b/idl/openbook_v2.json @@ -626,7 +626,7 @@ } }, { - "name": "cancelAndPlaceOrders", + "name": "cancelAllAndPlaceOrders", "docs": [ "Cancel orders and place multiple orders." ], @@ -707,18 +707,30 @@ ], "args": [ { - "name": "cancelClientOrdersIds", + "name": "ordersType", "type": { - "vec": "u64" + "defined": "PlaceOrderType" + } + }, + { + "name": "bids", + "type": { + "vec": { + "defined": "PlaceMultipleOrdersArgs" + } } }, { - "name": "placeOrders", + "name": "asks", "type": { "vec": { - "defined": "PlaceOrderArgs" + "defined": "PlaceMultipleOrdersArgs" } } + }, + { + "name": "limit", + "type": "u8" } ], "returns": { @@ -2817,6 +2829,26 @@ ] } }, + { + "name": "PlaceMultipleOrdersArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "priceLots", + "type": "i64" + }, + { + "name": "maxQuoteLotsIncludingFees", + "type": "i64" + }, + { + "name": "expiryTimestamp", + "type": "u64" + } + ] + } + }, { "name": "PlaceOrderPeggedArgs", "type": { diff --git a/package.json b/package.json index a772c8683..8df1f2c21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openbook-dex/openbook-v2", - "version": "0.1.0", + "version": "0.1.2", "description": "Typescript Client for openbook-v2 program.", "repository": "https://github.com/openbook-dex/openbook-v2/", "author": { diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index aacbe5c02..8858b3ac5 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -33,7 +33,10 @@ import { Side } from './utils/utils'; export type IdsSource = 'api' | 'static' | 'get-program-accounts'; export type PlaceOrderArgs = IdlTypes['PlaceOrderArgs']; +export type PlaceOrderType = IdlTypes['PlaceOrderType']; export type PlaceOrderPeggedArgs = IdlTypes['PlaceOrderPeggedArgs']; +export type PlaceMultipleOrdersArgs = + IdlTypes['PlaceMultipleOrdersArgs']; export type OracleConfigParams = IdlTypes['OracleConfigParams']; export type OracleConfig = IdlTypes['OracleConfig']; export type MarketAccount = IdlAccounts['market']; @@ -756,19 +759,22 @@ export class OpenBookV2Client { return [ix, signers]; } - public async cancelAndPlaceOrdersIx( + // Use OrderType from './utils/utils' for orderType + public async cancelAllAndPlaceOrdersIx( openOrdersPublicKey: PublicKey, marketPublicKey: PublicKey, market: MarketAccount, userBaseAccount: PublicKey, userQuoteAccount: PublicKey, openOrdersAdmin: PublicKey | null, - cancelClientOrdersIds: BN[], - placeOrders: PlaceOrderArgs[], + orderType: PlaceOrderType, + bids: PlaceMultipleOrdersArgs[], + asks: PlaceMultipleOrdersArgs[], + limit: number = 12, openOrdersDelegate?: Keypair, ): Promise<[TransactionInstruction, Signer[]]> { const ix = await this.program.methods - .cancelAndPlaceOrders(cancelClientOrdersIds, placeOrders) + .cancelAllAndPlaceOrders(orderType, bids, asks, limit) .accounts({ signer: openOrdersDelegate != null diff --git a/ts/client/src/openbook_v2.ts b/ts/client/src/openbook_v2.ts index cfd266749..78204c28b 100644 --- a/ts/client/src/openbook_v2.ts +++ b/ts/client/src/openbook_v2.ts @@ -622,7 +622,7 @@ export interface OpenbookV2 { }; }, { - name: 'cancelAndPlaceOrders'; + name: 'cancelAllAndPlaceOrders'; docs: ['Cancel orders and place multiple orders.']; accounts: [ { @@ -701,19 +701,31 @@ export interface OpenbookV2 { ]; args: [ { - name: 'cancelClientOrdersIds'; + name: 'ordersType'; type: { - vec: 'u64'; + defined: 'PlaceOrderType'; + }; + }, + { + name: 'bids'; + type: { + vec: { + defined: 'PlaceMultipleOrdersArgs'; + }; }; }, { - name: 'placeOrders'; + name: 'asks'; type: { vec: { - defined: 'PlaceOrderArgs'; + defined: 'PlaceMultipleOrdersArgs'; }; }; }, + { + name: 'limit'; + type: 'u8'; + }, ]; returns: { vec: { @@ -2666,6 +2678,26 @@ export interface OpenbookV2 { ]; }; }, + { + name: 'PlaceMultipleOrdersArgs'; + type: { + kind: 'struct'; + fields: [ + { + name: 'priceLots'; + type: 'i64'; + }, + { + name: 'maxQuoteLotsIncludingFees'; + type: 'i64'; + }, + { + name: 'expiryTimestamp'; + type: 'u64'; + }, + ]; + }; + }, { name: 'PlaceOrderPeggedArgs'; type: { @@ -4174,7 +4206,7 @@ export const IDL: OpenbookV2 = { }, }, { - name: 'cancelAndPlaceOrders', + name: 'cancelAllAndPlaceOrders', docs: ['Cancel orders and place multiple orders.'], accounts: [ { @@ -4253,19 +4285,31 @@ export const IDL: OpenbookV2 = { ], args: [ { - name: 'cancelClientOrdersIds', + name: 'ordersType', type: { - vec: 'u64', + defined: 'PlaceOrderType', + }, + }, + { + name: 'bids', + type: { + vec: { + defined: 'PlaceMultipleOrdersArgs', + }, }, }, { - name: 'placeOrders', + name: 'asks', type: { vec: { - defined: 'PlaceOrderArgs', + defined: 'PlaceMultipleOrdersArgs', }, }, }, + { + name: 'limit', + type: 'u8', + }, ], returns: { vec: { @@ -6218,6 +6262,26 @@ export const IDL: OpenbookV2 = { ], }, }, + { + name: 'PlaceMultipleOrdersArgs', + type: { + kind: 'struct', + fields: [ + { + name: 'priceLots', + type: 'i64', + }, + { + name: 'maxQuoteLotsIncludingFees', + type: 'i64', + }, + { + name: 'expiryTimestamp', + type: 'u64', + }, + ], + }, + }, { name: 'PlaceOrderPeggedArgs', type: {