Skip to content

Commit

Permalink
adjust client & bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
binyebarwe committed Dec 27, 2023
1 parent b728fe2 commit 5332d23
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 20 deletions.
42 changes: 37 additions & 5 deletions idl/openbook_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@
}
},
{
"name": "cancelAndPlaceOrders",
"name": "cancelAllAndPlaceOrders",
"docs": [
"Cancel orders and place multiple orders."
],
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
14 changes: 10 additions & 4 deletions ts/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ import { Side } from './utils/utils';

export type IdsSource = 'api' | 'static' | 'get-program-accounts';
export type PlaceOrderArgs = IdlTypes<OpenbookV2>['PlaceOrderArgs'];
export type PlaceOrderType = IdlTypes<OpenbookV2>['PlaceOrderType'];
export type PlaceOrderPeggedArgs = IdlTypes<OpenbookV2>['PlaceOrderPeggedArgs'];
export type PlaceMultipleOrdersArgs =
IdlTypes<OpenbookV2>['PlaceMultipleOrdersArgs'];
export type OracleConfigParams = IdlTypes<OpenbookV2>['OracleConfigParams'];
export type OracleConfig = IdlTypes<OpenbookV2>['OracleConfig'];
export type MarketAccount = IdlAccounts<OpenbookV2>['market'];
Expand Down Expand Up @@ -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
Expand Down
84 changes: 74 additions & 10 deletions ts/client/src/openbook_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ export interface OpenbookV2 {
};
},
{
name: 'cancelAndPlaceOrders';
name: 'cancelAllAndPlaceOrders';
docs: ['Cancel orders and place multiple orders.'];
accounts: [
{
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -4174,7 +4206,7 @@ export const IDL: OpenbookV2 = {
},
},
{
name: 'cancelAndPlaceOrders',
name: 'cancelAllAndPlaceOrders',
docs: ['Cancel orders and place multiple orders.'],
accounts: [
{
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 5332d23

Please sign in to comment.