@openbook-dex/openbook-v2
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -43,2 +43,4 @@ /// <reference types="bn.js" /> | ||
getBookSide(publicKey: PublicKey): Promise<BookSideAccount | null>; | ||
priceData(key: BN): number; | ||
getLeafNodes(bookside: BookSideAccount): LeafNode[]; | ||
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>; | ||
@@ -45,0 +47,0 @@ findOpenOrdersIndexer(market: PublicKey): PublicKey; |
@@ -111,2 +111,15 @@ "use strict"; | ||
} | ||
priceData(key) { | ||
const shiftedValue = key.shrn(64); // Shift right by 64 bits | ||
return shiftedValue.toNumber(); // Convert BN to a regular number | ||
} | ||
getLeafNodes(bookside) { | ||
const leafNodesData = bookside.nodes.nodes.filter((x) => x.tag === 2); | ||
const leafNodes = []; | ||
for (const x of leafNodesData) { | ||
const leafNode = this.program.coder.types.decode('LeafNode', Buffer.from([0, ...x.data])); | ||
leafNodes.push(leafNode); | ||
} | ||
return leafNodes; | ||
} | ||
async createMarket(payer, name, quoteMint, baseMint, quoteLoteSize, baseLoteSize, makerFee, takerFee, timeExpiry, oracleA, oracleB, openOrdersAdmin, consumeEventsAdmin, closeMarketAdmin, oracleConfigParams = { | ||
@@ -113,0 +126,0 @@ confFilter: 0.1, |
@@ -11,8 +11,8 @@ "use strict"; | ||
const connection = provider.connection; | ||
const latestBlockhash = opts.latestBlockhash ?? | ||
(await connection.getLatestBlockhash(opts.preflightCommitment ?? | ||
const latestBlockhash = opts?.latestBlockhash ?? | ||
(await connection.getLatestBlockhash(opts?.preflightCommitment ?? | ||
provider.opts.preflightCommitment ?? | ||
'finalized')); | ||
const payer = provider.wallet; | ||
if (opts.prioritizationFee !== null && opts.prioritizationFee !== 0) { | ||
if (opts?.prioritizationFee !== null && opts.prioritizationFee !== 0) { | ||
ixs = [(0, exports.createComputeBudgetIx)(opts.prioritizationFee), ...ixs]; | ||
@@ -27,3 +27,3 @@ } | ||
let vtx = new web3_js_1.VersionedTransaction(message); | ||
if (opts?.additionalSigners !== 'undefined' && | ||
if (opts?.additionalSigners !== undefined && | ||
opts?.additionalSigners.length !== 0) { | ||
@@ -49,4 +49,4 @@ vtx.sign([...opts?.additionalSigners]); | ||
// ); | ||
if (opts.postSendTxCallback !== null && | ||
opts.postSendTxCallback !== undefined) { | ||
if (opts?.postSendTxCallback !== undefined && | ||
opts?.postSendTxCallback !== null) { | ||
try { | ||
@@ -59,3 +59,3 @@ opts.postSendTxCallback({ txid: signature }); | ||
} | ||
const txConfirmationCommitment = opts.txConfirmationCommitment ?? 'processed'; | ||
const txConfirmationCommitment = opts?.txConfirmationCommitment ?? 'processed'; | ||
let status; | ||
@@ -62,0 +62,0 @@ if (latestBlockhash.blockhash != null && |
@@ -84,2 +84,15 @@ import { BN, Program, } from '@coral-xyz/anchor'; | ||
} | ||
priceData(key) { | ||
const shiftedValue = key.shrn(64); // Shift right by 64 bits | ||
return shiftedValue.toNumber(); // Convert BN to a regular number | ||
} | ||
getLeafNodes(bookside) { | ||
const leafNodesData = bookside.nodes.nodes.filter((x) => x.tag === 2); | ||
const leafNodes = []; | ||
for (const x of leafNodesData) { | ||
const leafNode = this.program.coder.types.decode('LeafNode', Buffer.from([0, ...x.data])); | ||
leafNodes.push(leafNode); | ||
} | ||
return leafNodes; | ||
} | ||
async createMarket(payer, name, quoteMint, baseMint, quoteLoteSize, baseLoteSize, makerFee, takerFee, timeExpiry, oracleA, oracleB, openOrdersAdmin, consumeEventsAdmin, closeMarketAdmin, oracleConfigParams = { | ||
@@ -86,0 +99,0 @@ confFilter: 0.1, |
@@ -5,8 +5,8 @@ import NodeWallet from '@coral-xyz/anchor/dist/cjs/nodewallet'; | ||
const connection = provider.connection; | ||
const latestBlockhash = opts.latestBlockhash ?? | ||
(await connection.getLatestBlockhash(opts.preflightCommitment ?? | ||
const latestBlockhash = opts?.latestBlockhash ?? | ||
(await connection.getLatestBlockhash(opts?.preflightCommitment ?? | ||
provider.opts.preflightCommitment ?? | ||
'finalized')); | ||
const payer = provider.wallet; | ||
if (opts.prioritizationFee !== null && opts.prioritizationFee !== 0) { | ||
if (opts?.prioritizationFee !== null && opts.prioritizationFee !== 0) { | ||
ixs = [createComputeBudgetIx(opts.prioritizationFee), ...ixs]; | ||
@@ -21,3 +21,3 @@ } | ||
let vtx = new VersionedTransaction(message); | ||
if (opts?.additionalSigners !== 'undefined' && | ||
if (opts?.additionalSigners !== undefined && | ||
opts?.additionalSigners.length !== 0) { | ||
@@ -43,4 +43,4 @@ vtx.sign([...opts?.additionalSigners]); | ||
// ); | ||
if (opts.postSendTxCallback !== null && | ||
opts.postSendTxCallback !== undefined) { | ||
if (opts?.postSendTxCallback !== undefined && | ||
opts?.postSendTxCallback !== null) { | ||
try { | ||
@@ -53,3 +53,3 @@ opts.postSendTxCallback({ txid: signature }); | ||
} | ||
const txConfirmationCommitment = opts.txConfirmationCommitment ?? 'processed'; | ||
const txConfirmationCommitment = opts?.txConfirmationCommitment ?? 'processed'; | ||
let status; | ||
@@ -56,0 +56,0 @@ if (latestBlockhash.blockhash != null && |
@@ -43,2 +43,4 @@ /// <reference types="bn.js" /> | ||
getBookSide(publicKey: PublicKey): Promise<BookSideAccount | null>; | ||
priceData(key: BN): number; | ||
getLeafNodes(bookside: BookSideAccount): LeafNode[]; | ||
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>; | ||
@@ -45,0 +47,0 @@ findOpenOrdersIndexer(market: PublicKey): PublicKey; |
{ | ||
"name": "@openbook-dex/openbook-v2", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Typescript Client for openbook-v2 program.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/openbook-dex/openbook-v2/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
538364
14710