Skip to content

Commit

Permalink
add placeOrders to the sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
binyebarwe committed Feb 2, 2024
1 parent 23fc295 commit 1a995c6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
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.8",
"version": "0.1.9",
"description": "Typescript Client for openbook-v2 program.",
"repository": "https://github.com/openbook-dex/openbook-v2/",
"author": {
Expand Down
43 changes: 43 additions & 0 deletions ts/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,49 @@ export class OpenBookV2Client {
return [ix, signers];
}

// Use OrderType from './utils/utils' for orderType
public async placeOrdersIx(
openOrdersPublicKey: PublicKey,
marketPublicKey: PublicKey,
market: MarketAccount,
userBaseAccount: PublicKey,
userQuoteAccount: PublicKey,
openOrdersAdmin: PublicKey | null,
orderType: PlaceOrderType,
bids: PlaceMultipleOrdersArgs[],
asks: PlaceMultipleOrdersArgs[],
limit: number = 12,
openOrdersDelegate?: Keypair,
): Promise<[TransactionInstruction, Signer[]]> {
const ix = await this.program.methods
.placeOrders(orderType, bids, asks, limit)
.accounts({
signer:
openOrdersDelegate != null
? openOrdersDelegate.publicKey
: this.walletPk,
asks: market.asks,
bids: market.bids,
marketQuoteVault: market.marketQuoteVault,
marketBaseVault: market.marketBaseVault,
eventHeap: market.eventHeap,
market: marketPublicKey,
openOrdersAccount: openOrdersPublicKey,
oracleA: market.oracleA.key,
oracleB: market.oracleB.key,
userBaseAccount,
userQuoteAccount,
tokenProgram: TOKEN_PROGRAM_ID,
openOrdersAdmin,
})
.instruction();
const signers: Signer[] = [];
if (openOrdersDelegate != null) {
signers.push(openOrdersDelegate);
}
return [ix, signers];
}

public async cancelOrderById(
openOrdersPublicKey: PublicKey,
openOrdersAccount: OpenOrdersAccount,
Expand Down

0 comments on commit 1a995c6

Please sign in to comment.