Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openbook-dex/openbook-v2

Package Overview
Dependencies
Maintainers
2
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openbook-dex/openbook-v2 - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

22

dist/cjs/client.d.ts
/// <reference types="bn.js" />
/// <reference types="node" />
import { BN, type Program, type IdlTypes, type IdlAccounts } from '@coral-xyz/anchor';
import { type AnchorProvider, BN, Program, type IdlTypes, type IdlAccounts } from '@coral-xyz/anchor';
import { type RawMint } from '@solana/spl-token';
import { type AccountInfo, type Cluster, type Commitment, type Connection, Keypair, PublicKey, type TransactionInstruction, type TransactionSignature } from '@solana/web3.js';
import { type AccountInfo, type Commitment, type Connection, Keypair, PublicKey, type TransactionInstruction, type TransactionSignature } from '@solana/web3.js';
import { type OpenbookV2 } from './openbook_v2';

@@ -15,2 +15,4 @@ export type IdsSource = 'api' | 'static' | 'get-program-accounts';

export type BookSideAccount = IdlAccounts<OpenbookV2>['bookSide'];
export type LeafNode = IdlTypes<OpenbookV2>['LeafNode'];
export type AnyNode = IdlTypes<OpenbookV2>['AnyNode'];
export interface OpenBookClientOptions {

@@ -26,6 +28,6 @@ idsSource?: IdsSource;

export declare class OpenBookV2Client {
program: Program<OpenbookV2>;
programId: PublicKey;
cluster: Cluster;
provider: AnchorProvider;
opts: OpenBookClientOptions;
program: Program<OpenbookV2>;
private readonly idsSource;

@@ -35,3 +37,3 @@ private readonly postSendTxCallback?;

private readonly txConfirmationCommitment;
constructor(program: Program<OpenbookV2>, programId: PublicKey, cluster: Cluster, opts?: OpenBookClientOptions);
constructor(programId: PublicKey, provider: AnchorProvider, opts?: OpenBookClientOptions);
get connection(): Connection;

@@ -44,8 +46,12 @@ get walletPk(): PublicKey;

getBookSide(publicKey: PublicKey): Promise<BookSideAccount | null>;
createMarket(payer: Keypair, name: string, quoteMint: PublicKey, baseMint: PublicKey, quoteLoteSize: BN, baseLoteSize: BN, makerFee: BN, takerFee: BN, timeExpiry: BN, oracleA: PublicKey, oracleB: PublicKey, oracleConfigParams?: OracleConfigParams): Promise<TransactionSignature>;
createMarket(payer: Keypair, name: string, quoteMint: PublicKey, baseMint: PublicKey, quoteLoteSize: BN, baseLoteSize: BN, makerFee: BN, takerFee: BN, timeExpiry: BN, oracleA: PublicKey | null, oracleB: PublicKey | null, openOrdersAdmin: PublicKey | null, consumeEventsAdmin: PublicKey | null, closeMarketAdmin: PublicKey | null, oracleConfigParams?: OracleConfigParams, collectFeeAdmin?: PublicKey): Promise<TransactionSignature>;
findOpenOrdersIndexer(market: PublicKey): PublicKey;
createOpenOrdersIndexer(market: PublicKey, openOrdersIndexer: PublicKey): Promise<TransactionSignature>;
findOpenOrders(market: PublicKey, accountIndex: BN): PublicKey;
createOpenOrders(market: PublicKey, accountIndex: BN, openOrdersIndexer?: PublicKey): Promise<TransactionSignature>;
deposit(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, userBaseAccount: PublicKey, userQuoteAccount: PublicKey, baseAmount: BN, quoteAmount: BN): Promise<TransactionSignature>;
depositNative(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, userBaseAccount: PublicKey, userQuoteAccount: PublicKey, baseAmount: BN, quoteAmount: BN): Promise<TransactionSignature>;
decodeMarket(data: Buffer): any;
placeOrder(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, userTokenAccount: PublicKey, openOrdersAdmin: PublicKey | null, args: PlaceOrderArgs, openOrdersDelegate?: Keypair): Promise<TransactionSignature>;
cancelAndPlaceOrders(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, userBaseAccount: PublicKey, userQuoteAccount: PublicKey, openOrdersAdmin: PublicKey | null, cancelClientOrdersIds: BN[], placeOrders: PlaceOrderArgs[], openOrdersDelegate?: Keypair): Promise<TransactionSignature>;
placeOrder(openOrdersPublicKey: PublicKey, marketPublicKey: PublicKey, market: MarketAccount, userTokenAccount: PublicKey, openOrdersAdmin: PublicKey | null, args: PlaceOrderArgs, openOrdersDelegate?: Keypair): Promise<TransactionSignature>;
cancelAndPlaceOrders(openOrdersPublicKey: PublicKey, marketPublicKey: PublicKey, market: MarketAccount, userBaseAccount: PublicKey, userQuoteAccount: PublicKey, openOrdersAdmin: PublicKey | null, cancelClientOrdersIds: BN[], placeOrders: PlaceOrderArgs[], openOrdersDelegate?: Keypair): Promise<TransactionSignature>;
cancelOrderById(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, orderId: BN, openOrdersDelegate?: Keypair): Promise<TransactionSignature>;

@@ -52,0 +58,0 @@ cancelOrderByClientId(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, clientOrderId: BN, openOrdersDelegate?: Keypair): Promise<TransactionSignature>;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,2 +31,4 @@ exports.getFilteredProgramAccounts = exports.decodeMint = exports.OpenBookV2Client = exports.nameToString = void 0;

const web3_js_1 = require("@solana/web3.js");
const splToken = __importStar(require("@solana/spl-token"));
const openbook_v2_1 = require("./openbook_v2");
const rpc_1 = require("./utils/rpc");

@@ -16,6 +41,6 @@ const utils_1 = require("./utils/utils");

class OpenBookV2Client {
program;
programId;
cluster;
provider;
opts;
program;
idsSource;

@@ -25,7 +50,7 @@ postSendTxCallback;

txConfirmationCommitment;
constructor(program, programId, cluster, opts = {}) {
this.program = program;
constructor(programId, provider, opts = {}) {
this.programId = programId;
this.cluster = cluster;
this.provider = provider;
this.opts = opts;
this.program = new anchor_1.Program(openbook_v2_1.IDL, programId, provider);
this.idsSource = opts.idsSource ?? 'get-program-accounts';

@@ -36,3 +61,3 @@ this.prioritizationFee = opts?.prioritizationFee ?? 0;

opts?.txConfirmationCommitment ??
program.provider.opts.commitment ??
this.program.provider.opts.commitment ??
'processed';

@@ -90,14 +115,6 @@ // TODO: evil side effect, but limited backtraces are a nightmare

}
// public async getOpenOrdersAccountFromPublicKey(
// publicKey: PublicKey,
// ): Promise<Market | null> {
// const account = await this.connection.getAccountInfo(publicKey);
// if (account != null) {
// }
// return null;
// }
async createMarket(payer, name, quoteMint, baseMint, quoteLoteSize, baseLoteSize, makerFee, takerFee, timeExpiry, oracleA, oracleB, oracleConfigParams = {
async createMarket(payer, name, quoteMint, baseMint, quoteLoteSize, baseLoteSize, makerFee, takerFee, timeExpiry, oracleA, oracleB, openOrdersAdmin, consumeEventsAdmin, closeMarketAdmin, oracleConfigParams = {
confFilter: 0.1,
maxStalenessSlots: 100,
}) {
}, collectFeeAdmin) {
const bids = web3_js_1.Keypair.generate().publicKey;

@@ -131,5 +148,4 @@ const booksideSpace = 123720;

const [marketAuthority] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('Market'), market.publicKey.toBuffer()], this.program.programId);
// Usage
const baseVault = await (0, spl_token_1.getOrCreateAssociatedTokenAccount)(this.connection, payer, baseMint, this.programId, true, undefined, undefined, spl_token_1.TOKEN_PROGRAM_ID, marketAuthority);
const quoteVault = await (0, spl_token_1.getOrCreateAssociatedTokenAccount)(this.connection, payer, quoteMint, this.programId, true, undefined, undefined, spl_token_1.TOKEN_PROGRAM_ID, marketAuthority);
const baseVault = await splToken.createAccount(this.connection, payer, baseMint, marketAuthority, web3_js_1.Keypair.generate());
const quoteVault = await splToken.createAccount(this.connection, payer, quoteMint, marketAuthority, web3_js_1.Keypair.generate());
const [eventAuthority] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('__event_authority')], this.program.programId);

@@ -147,4 +163,4 @@ const ix = await this.program.methods

payer: payer.publicKey,
marketBaseVault: baseVault.address,
marketQuoteVault: quoteVault.address,
marketBaseVault: baseVault,
marketQuoteVault: quoteVault,
baseMint,

@@ -155,2 +171,6 @@ quoteMint,

program: this.programId,
collectFeeAdmin: collectFeeAdmin != null ? collectFeeAdmin : payer.publicKey,
openOrdersAdmin,
consumeEventsAdmin,
closeMarketAdmin,
})

@@ -160,2 +180,56 @@ .instruction();

}
findOpenOrdersIndexer(market) {
const [openOrdersIndexer] = web3_js_1.PublicKey.findProgramAddressSync([
Buffer.from('OpenOrdersIndexer'),
this.walletPk.toBuffer(),
market.toBuffer(),
], this.programId);
return openOrdersIndexer;
}
async createOpenOrdersIndexer(market, openOrdersIndexer) {
const ix = await this.program.methods
.createOpenOrdersIndexer()
.accounts({
openOrdersIndexer,
market,
owner: this.walletPk,
payer: this.walletPk,
systemProgram: web3_js_1.SystemProgram.programId,
})
.instruction();
return await this.sendAndConfirmTransaction([ix]);
}
findOpenOrders(market, accountIndex) {
const [openOrders] = web3_js_1.PublicKey.findProgramAddressSync([
Buffer.from('OpenOrders'),
this.walletPk.toBuffer(),
market.toBuffer(),
accountIndex.toBuffer('le', 4),
], this.programId);
return openOrders;
}
async createOpenOrders(market, accountIndex, openOrdersIndexer) {
if (openOrdersIndexer == null) {
openOrdersIndexer = this.findOpenOrdersIndexer(market);
const acc = await this.connection.getAccountInfo(openOrdersIndexer);
if (acc == null) {
const tx = await this.createOpenOrdersIndexer(market, openOrdersIndexer);
console.log('Created open orders indexer', tx);
}
}
const openOrders = this.findOpenOrders(market, accountIndex);
const ix = await this.program.methods
.createOpenOrdersAccount()
.accounts({
openOrdersIndexer,
openOrdersAccount: openOrders,
market,
owner: this.walletPk,
delegateAccount: null,
payer: this.walletPk,
systemProgram: web3_js_1.SystemProgram.programId,
})
.instruction();
return await this.sendAndConfirmTransaction([ix]);
}
async deposit(openOrdersPublicKey, openOrdersAccount, market, userBaseAccount, userQuoteAccount, baseAmount, quoteAmount) {

@@ -217,3 +291,3 @@ const ix = await this.program.methods

}
async placeOrder(openOrdersPublicKey, openOrdersAccount, market, userTokenAccount, openOrdersAdmin, args, openOrdersDelegate) {
async placeOrder(openOrdersPublicKey, marketPublicKey, market, userTokenAccount, openOrdersAdmin, args, openOrdersDelegate) {
const marketVault = args.side === utils_1.Side.Bid ? market.marketQuoteVault : market.marketBaseVault;

@@ -223,3 +297,5 @@ const ix = await this.program.methods

.accounts({
signer: openOrdersAccount.owner,
signer: openOrdersDelegate != null
? openOrdersDelegate.publicKey
: this.walletPk,
asks: market.asks,

@@ -229,3 +305,3 @@ bids: market.bids,

eventQueue: market.eventQueue,
market: openOrdersAccount.market,
market: marketPublicKey,
openOrdersAccount: openOrdersPublicKey,

@@ -246,7 +322,9 @@ oracleA: market.oracleA.key,

}
async cancelAndPlaceOrders(openOrdersPublicKey, openOrdersAccount, market, userBaseAccount, userQuoteAccount, openOrdersAdmin, cancelClientOrdersIds, placeOrders, openOrdersDelegate) {
async cancelAndPlaceOrders(openOrdersPublicKey, marketPublicKey, market, userBaseAccount, userQuoteAccount, openOrdersAdmin, cancelClientOrdersIds, placeOrders, openOrdersDelegate) {
const ix = await this.program.methods
.cancelAndPlaceOrders(cancelClientOrdersIds, placeOrders)
.accounts({
signer: openOrdersAccount.owner,
signer: openOrdersDelegate != null
? openOrdersDelegate.publicKey
: this.walletPk,
asks: market.asks,

@@ -257,3 +335,3 @@ bids: market.bids,

eventQueue: market.eventQueue,
market: openOrdersAccount.market,
market: marketPublicKey,
openOrdersAccount: openOrdersPublicKey,

@@ -260,0 +338,0 @@ oracleA: market.oracleA.key,

@@ -26,3 +26,4 @@ "use strict";

let vtx = new web3_js_1.VersionedTransaction(message);
if (opts?.additionalSigners?.length !== 0) {
if (opts?.additionalSigners !== 'undefined' &&
opts?.additionalSigners.length !== 0) {
vtx.sign([...opts?.additionalSigners]);

@@ -69,5 +70,5 @@ }

}
if (status.err !== '') {
if (status.err !== '' && status.err !== null) {
console.warn('Tx status: ', status);
throw new MangoError({
throw new OpenBookError({
txid: signature,

@@ -87,3 +88,3 @@ message: `${JSON.stringify(status)}`,

exports.createComputeBudgetIx = createComputeBudgetIx;
class MangoError extends Error {
class OpenBookError extends Error {
message;

@@ -90,0 +91,0 @@ txid;

@@ -1,5 +0,7 @@

import { BN, } from '@coral-xyz/anchor';
import { BN, Program, } from '@coral-xyz/anchor';
import { utf8 } from '@coral-xyz/anchor/dist/cjs/utils/bytes';
import { MintLayout, NATIVE_MINT, TOKEN_PROGRAM_ID, createCloseAccountInstruction, createInitializeAccount3Instruction, getOrCreateAssociatedTokenAccount, } from '@solana/spl-token';
import { MintLayout, NATIVE_MINT, TOKEN_PROGRAM_ID, createCloseAccountInstruction, createInitializeAccount3Instruction, } from '@solana/spl-token';
import { Keypair, PublicKey, SystemProgram, } from '@solana/web3.js';
import * as splToken from '@solana/spl-token';
import { IDL } from './openbook_v2';
import { sendTransaction } from './utils/rpc';

@@ -11,6 +13,6 @@ import { Side } from './utils/utils';

export class OpenBookV2Client {
program;
programId;
cluster;
provider;
opts;
program;
idsSource;

@@ -20,7 +22,7 @@ postSendTxCallback;

txConfirmationCommitment;
constructor(program, programId, cluster, opts = {}) {
this.program = program;
constructor(programId, provider, opts = {}) {
this.programId = programId;
this.cluster = cluster;
this.provider = provider;
this.opts = opts;
this.program = new Program(IDL, programId, provider);
this.idsSource = opts.idsSource ?? 'get-program-accounts';

@@ -31,3 +33,3 @@ this.prioritizationFee = opts?.prioritizationFee ?? 0;

opts?.txConfirmationCommitment ??
program.provider.opts.commitment ??
this.program.provider.opts.commitment ??
'processed';

@@ -85,14 +87,6 @@ // TODO: evil side effect, but limited backtraces are a nightmare

}
// public async getOpenOrdersAccountFromPublicKey(
// publicKey: PublicKey,
// ): Promise<Market | null> {
// const account = await this.connection.getAccountInfo(publicKey);
// if (account != null) {
// }
// return null;
// }
async createMarket(payer, name, quoteMint, baseMint, quoteLoteSize, baseLoteSize, makerFee, takerFee, timeExpiry, oracleA, oracleB, oracleConfigParams = {
async createMarket(payer, name, quoteMint, baseMint, quoteLoteSize, baseLoteSize, makerFee, takerFee, timeExpiry, oracleA, oracleB, openOrdersAdmin, consumeEventsAdmin, closeMarketAdmin, oracleConfigParams = {
confFilter: 0.1,
maxStalenessSlots: 100,
}) {
}, collectFeeAdmin) {
const bids = Keypair.generate().publicKey;

@@ -126,5 +120,4 @@ const booksideSpace = 123720;

const [marketAuthority] = PublicKey.findProgramAddressSync([Buffer.from('Market'), market.publicKey.toBuffer()], this.program.programId);
// Usage
const baseVault = await getOrCreateAssociatedTokenAccount(this.connection, payer, baseMint, this.programId, true, undefined, undefined, TOKEN_PROGRAM_ID, marketAuthority);
const quoteVault = await getOrCreateAssociatedTokenAccount(this.connection, payer, quoteMint, this.programId, true, undefined, undefined, TOKEN_PROGRAM_ID, marketAuthority);
const baseVault = await splToken.createAccount(this.connection, payer, baseMint, marketAuthority, Keypair.generate());
const quoteVault = await splToken.createAccount(this.connection, payer, quoteMint, marketAuthority, Keypair.generate());
const [eventAuthority] = PublicKey.findProgramAddressSync([Buffer.from('__event_authority')], this.program.programId);

@@ -142,4 +135,4 @@ const ix = await this.program.methods

payer: payer.publicKey,
marketBaseVault: baseVault.address,
marketQuoteVault: quoteVault.address,
marketBaseVault: baseVault,
marketQuoteVault: quoteVault,
baseMint,

@@ -150,2 +143,6 @@ quoteMint,

program: this.programId,
collectFeeAdmin: collectFeeAdmin != null ? collectFeeAdmin : payer.publicKey,
openOrdersAdmin,
consumeEventsAdmin,
closeMarketAdmin,
})

@@ -155,2 +152,56 @@ .instruction();

}
findOpenOrdersIndexer(market) {
const [openOrdersIndexer] = PublicKey.findProgramAddressSync([
Buffer.from('OpenOrdersIndexer'),
this.walletPk.toBuffer(),
market.toBuffer(),
], this.programId);
return openOrdersIndexer;
}
async createOpenOrdersIndexer(market, openOrdersIndexer) {
const ix = await this.program.methods
.createOpenOrdersIndexer()
.accounts({
openOrdersIndexer,
market,
owner: this.walletPk,
payer: this.walletPk,
systemProgram: SystemProgram.programId,
})
.instruction();
return await this.sendAndConfirmTransaction([ix]);
}
findOpenOrders(market, accountIndex) {
const [openOrders] = PublicKey.findProgramAddressSync([
Buffer.from('OpenOrders'),
this.walletPk.toBuffer(),
market.toBuffer(),
accountIndex.toBuffer('le', 4),
], this.programId);
return openOrders;
}
async createOpenOrders(market, accountIndex, openOrdersIndexer) {
if (openOrdersIndexer == null) {
openOrdersIndexer = this.findOpenOrdersIndexer(market);
const acc = await this.connection.getAccountInfo(openOrdersIndexer);
if (acc == null) {
const tx = await this.createOpenOrdersIndexer(market, openOrdersIndexer);
console.log('Created open orders indexer', tx);
}
}
const openOrders = this.findOpenOrders(market, accountIndex);
const ix = await this.program.methods
.createOpenOrdersAccount()
.accounts({
openOrdersIndexer,
openOrdersAccount: openOrders,
market,
owner: this.walletPk,
delegateAccount: null,
payer: this.walletPk,
systemProgram: SystemProgram.programId,
})
.instruction();
return await this.sendAndConfirmTransaction([ix]);
}
async deposit(openOrdersPublicKey, openOrdersAccount, market, userBaseAccount, userQuoteAccount, baseAmount, quoteAmount) {

@@ -212,3 +263,3 @@ const ix = await this.program.methods

}
async placeOrder(openOrdersPublicKey, openOrdersAccount, market, userTokenAccount, openOrdersAdmin, args, openOrdersDelegate) {
async placeOrder(openOrdersPublicKey, marketPublicKey, market, userTokenAccount, openOrdersAdmin, args, openOrdersDelegate) {
const marketVault = args.side === Side.Bid ? market.marketQuoteVault : market.marketBaseVault;

@@ -218,3 +269,5 @@ const ix = await this.program.methods

.accounts({
signer: openOrdersAccount.owner,
signer: openOrdersDelegate != null
? openOrdersDelegate.publicKey
: this.walletPk,
asks: market.asks,

@@ -224,3 +277,3 @@ bids: market.bids,

eventQueue: market.eventQueue,
market: openOrdersAccount.market,
market: marketPublicKey,
openOrdersAccount: openOrdersPublicKey,

@@ -241,7 +294,9 @@ oracleA: market.oracleA.key,

}
async cancelAndPlaceOrders(openOrdersPublicKey, openOrdersAccount, market, userBaseAccount, userQuoteAccount, openOrdersAdmin, cancelClientOrdersIds, placeOrders, openOrdersDelegate) {
async cancelAndPlaceOrders(openOrdersPublicKey, marketPublicKey, market, userBaseAccount, userQuoteAccount, openOrdersAdmin, cancelClientOrdersIds, placeOrders, openOrdersDelegate) {
const ix = await this.program.methods
.cancelAndPlaceOrders(cancelClientOrdersIds, placeOrders)
.accounts({
signer: openOrdersAccount.owner,
signer: openOrdersDelegate != null
? openOrdersDelegate.publicKey
: this.walletPk,
asks: market.asks,

@@ -252,3 +307,3 @@ bids: market.bids,

eventQueue: market.eventQueue,
market: openOrdersAccount.market,
market: marketPublicKey,
openOrdersAccount: openOrdersPublicKey,

@@ -255,0 +310,0 @@ oracleA: market.oracleA.key,

@@ -20,3 +20,4 @@ import NodeWallet from '@coral-xyz/anchor/dist/cjs/nodewallet';

let vtx = new VersionedTransaction(message);
if (opts?.additionalSigners?.length !== 0) {
if (opts?.additionalSigners !== 'undefined' &&
opts?.additionalSigners.length !== 0) {
vtx.sign([...opts?.additionalSigners]);

@@ -63,5 +64,5 @@ }

}
if (status.err !== '') {
if (status.err !== '' && status.err !== null) {
console.warn('Tx status: ', status);
throw new MangoError({
throw new OpenBookError({
txid: signature,

@@ -79,3 +80,3 @@ message: `${JSON.stringify(status)}`,

};
class MangoError extends Error {
class OpenBookError extends Error {
message;

@@ -82,0 +83,0 @@ txid;

/// <reference types="bn.js" />
/// <reference types="node" />
import { BN, type Program, type IdlTypes, type IdlAccounts } from '@coral-xyz/anchor';
import { type AnchorProvider, BN, Program, type IdlTypes, type IdlAccounts } from '@coral-xyz/anchor';
import { type RawMint } from '@solana/spl-token';
import { type AccountInfo, type Cluster, type Commitment, type Connection, Keypair, PublicKey, type TransactionInstruction, type TransactionSignature } from '@solana/web3.js';
import { type AccountInfo, type Commitment, type Connection, Keypair, PublicKey, type TransactionInstruction, type TransactionSignature } from '@solana/web3.js';
import { type OpenbookV2 } from './openbook_v2';

@@ -15,2 +15,4 @@ export type IdsSource = 'api' | 'static' | 'get-program-accounts';

export type BookSideAccount = IdlAccounts<OpenbookV2>['bookSide'];
export type LeafNode = IdlTypes<OpenbookV2>['LeafNode'];
export type AnyNode = IdlTypes<OpenbookV2>['AnyNode'];
export interface OpenBookClientOptions {

@@ -26,6 +28,6 @@ idsSource?: IdsSource;

export declare class OpenBookV2Client {
program: Program<OpenbookV2>;
programId: PublicKey;
cluster: Cluster;
provider: AnchorProvider;
opts: OpenBookClientOptions;
program: Program<OpenbookV2>;
private readonly idsSource;

@@ -35,3 +37,3 @@ private readonly postSendTxCallback?;

private readonly txConfirmationCommitment;
constructor(program: Program<OpenbookV2>, programId: PublicKey, cluster: Cluster, opts?: OpenBookClientOptions);
constructor(programId: PublicKey, provider: AnchorProvider, opts?: OpenBookClientOptions);
get connection(): Connection;

@@ -44,8 +46,12 @@ get walletPk(): PublicKey;

getBookSide(publicKey: PublicKey): Promise<BookSideAccount | null>;
createMarket(payer: Keypair, name: string, quoteMint: PublicKey, baseMint: PublicKey, quoteLoteSize: BN, baseLoteSize: BN, makerFee: BN, takerFee: BN, timeExpiry: BN, oracleA: PublicKey, oracleB: PublicKey, oracleConfigParams?: OracleConfigParams): Promise<TransactionSignature>;
createMarket(payer: Keypair, name: string, quoteMint: PublicKey, baseMint: PublicKey, quoteLoteSize: BN, baseLoteSize: BN, makerFee: BN, takerFee: BN, timeExpiry: BN, oracleA: PublicKey | null, oracleB: PublicKey | null, openOrdersAdmin: PublicKey | null, consumeEventsAdmin: PublicKey | null, closeMarketAdmin: PublicKey | null, oracleConfigParams?: OracleConfigParams, collectFeeAdmin?: PublicKey): Promise<TransactionSignature>;
findOpenOrdersIndexer(market: PublicKey): PublicKey;
createOpenOrdersIndexer(market: PublicKey, openOrdersIndexer: PublicKey): Promise<TransactionSignature>;
findOpenOrders(market: PublicKey, accountIndex: BN): PublicKey;
createOpenOrders(market: PublicKey, accountIndex: BN, openOrdersIndexer?: PublicKey): Promise<TransactionSignature>;
deposit(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, userBaseAccount: PublicKey, userQuoteAccount: PublicKey, baseAmount: BN, quoteAmount: BN): Promise<TransactionSignature>;
depositNative(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, userBaseAccount: PublicKey, userQuoteAccount: PublicKey, baseAmount: BN, quoteAmount: BN): Promise<TransactionSignature>;
decodeMarket(data: Buffer): any;
placeOrder(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, userTokenAccount: PublicKey, openOrdersAdmin: PublicKey | null, args: PlaceOrderArgs, openOrdersDelegate?: Keypair): Promise<TransactionSignature>;
cancelAndPlaceOrders(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, userBaseAccount: PublicKey, userQuoteAccount: PublicKey, openOrdersAdmin: PublicKey | null, cancelClientOrdersIds: BN[], placeOrders: PlaceOrderArgs[], openOrdersDelegate?: Keypair): Promise<TransactionSignature>;
placeOrder(openOrdersPublicKey: PublicKey, marketPublicKey: PublicKey, market: MarketAccount, userTokenAccount: PublicKey, openOrdersAdmin: PublicKey | null, args: PlaceOrderArgs, openOrdersDelegate?: Keypair): Promise<TransactionSignature>;
cancelAndPlaceOrders(openOrdersPublicKey: PublicKey, marketPublicKey: PublicKey, market: MarketAccount, userBaseAccount: PublicKey, userQuoteAccount: PublicKey, openOrdersAdmin: PublicKey | null, cancelClientOrdersIds: BN[], placeOrders: PlaceOrderArgs[], openOrdersDelegate?: Keypair): Promise<TransactionSignature>;
cancelOrderById(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, orderId: BN, openOrdersDelegate?: Keypair): Promise<TransactionSignature>;

@@ -52,0 +58,0 @@ cancelOrderByClientId(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, clientOrderId: BN, openOrdersDelegate?: Keypair): Promise<TransactionSignature>;

{
"name": "@openbook-dex/openbook-v2",
"version": "0.0.1",
"version": "0.0.2",
"description": "Typescript Client for openbook-v2 program.",

@@ -5,0 +5,0 @@ "repository": "https://github.com/openbook-dex/openbook-v2/",

@@ -28,7 +28,7 @@ # OpenBook V2

| tag  | network | program ID |
| ---- | ------- | -------------------------------------------- |
| v0.1 | mainnet | opnbkNkqux64GppQhwbyEVc3axhssFhVYuwar8rDHCuA |
| v0.1 | devnet | opnbkNkqux64GppQhwbyEVc3axhssFhVYuwar8rDHCuA |
| v0.1 | testnet | opnbkNkqux64GppQhwbyEVc3axhssFhVYuwar8rDHCuA |
| tag  | network | program ID |
| ---- | ------- | ------------------------------------------- |
| v0.1 | mainnet | opnbkNkqux64GppQhwbyEVc3axhssFhVYuwar8rDHCu |
| v0.1 | devnet | opnbkNkqux64GppQhwbyEVc3axhssFhVYuwar8rDHCu |
| v0.1 | testnet | opnbkNkqux64GppQhwbyEVc3axhssFhVYuwar8rDHCu |

@@ -43,3 +43,3 @@ ## Building & testing

- [Solana](https://docs.solana.com/cli/install-solana-cli-tools)
- [Anchor](https://www.anchor-lang.com/docs/installation) (v0.27.0)
- [Anchor](https://www.anchor-lang.com/docs/installation) (v0.28.0)
- [Just](https://github.com/casey/just#installation)

@@ -46,0 +46,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc