@openbook-dex/openbook-v2
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -5,3 +5,3 @@ /// <reference types="bn.js" /> | ||
import { type RawMint } from '@solana/spl-token'; | ||
import { type AccountInfo, type Commitment, type Connection, Keypair, PublicKey, type TransactionInstruction, type TransactionSignature } from '@solana/web3.js'; | ||
import { type AccountInfo, type Commitment, type Connection, Keypair, PublicKey, type Signer, type TransactionInstruction, type TransactionSignature } from '@solana/web3.js'; | ||
import { type OpenbookV2 } from './openbook_v2'; | ||
@@ -45,3 +45,4 @@ export type IdsSource = 'api' | 'static' | 'get-program-accounts'; | ||
sendAndConfirmTransaction(ixs: TransactionInstruction[], opts?: any): Promise<string>; | ||
createProgramAccount(authority: Keypair, size: number): Promise<PublicKey>; | ||
createProgramAccount(authority: PublicKey, size: number): Promise<PublicKey>; | ||
createProgramAccountIx(authority: PublicKey, size: number): Promise<[TransactionInstruction, Signer]>; | ||
getMarketAccount(publicKey: PublicKey): Promise<MarketAccount | null>; | ||
@@ -54,3 +55,3 @@ getOpenOrders(publicKey: PublicKey): Promise<OpenOrdersAccount | null>; | ||
getLeafNodes(bookside: BookSideAccount): LeafNode[]; | ||
createMarket(payer: Keypair, name: string, quoteMint: PublicKey, baseMint: PublicKey, quoteLotSize: BN, baseLotSize: BN, makerFee: BN, takerFee: BN, timeExpiry: BN, oracleA: PublicKey | null, oracleB: PublicKey | null, openOrdersAdmin: PublicKey | null, consumeEventsAdmin: PublicKey | null, closeMarketAdmin: PublicKey | null, oracleConfigParams?: OracleConfigParams, market?: Keypair, collectFeeAdmin?: PublicKey): Promise<PublicKey>; | ||
createMarket(payer: PublicKey, name: string, quoteMint: PublicKey, baseMint: PublicKey, quoteLotSize: BN, baseLotSize: BN, makerFee: BN, takerFee: BN, timeExpiry: BN, oracleA: PublicKey | null, oracleB: PublicKey | null, openOrdersAdmin: PublicKey | null, consumeEventsAdmin: PublicKey | null, closeMarketAdmin: PublicKey | null, oracleConfigParams?: OracleConfigParams, market?: Keypair, collectFeeAdmin?: PublicKey): Promise<[TransactionInstruction[], Signer[]]>; | ||
closeMarket(marketPublicKey: PublicKey, market: MarketAccount, solDestination: PublicKey, closeMarketAdmin?: Keypair | null): Promise<TransactionSignature>; | ||
@@ -57,0 +58,0 @@ findOpenOrdersIndexer(owner?: PublicKey): PublicKey; |
@@ -64,3 +64,3 @@ "use strict"; | ||
const tx = new web3_js_1.Transaction().add(web3_js_1.SystemProgram.createAccount({ | ||
fromPubkey: authority.publicKey, | ||
fromPubkey: authority, | ||
newAccountPubkey: address.publicKey, | ||
@@ -72,6 +72,18 @@ lamports, | ||
await this.sendAndConfirmTransaction(tx, { | ||
additionalSigners: [authority, address], | ||
additionalSigners: [address], | ||
}); | ||
return address.publicKey; | ||
} | ||
async createProgramAccountIx(authority, size) { | ||
const lamports = await this.connection.getMinimumBalanceForRentExemption(size); | ||
const address = web3_js_1.Keypair.generate(); | ||
const ix = web3_js_1.SystemProgram.createAccount({ | ||
fromPubkey: authority, | ||
newAccountPubkey: address.publicKey, | ||
lamports, | ||
space: size, | ||
programId: this.programId, | ||
}); | ||
return [ix, address]; | ||
} | ||
// Get the MarketAccount from the market publicKey | ||
@@ -135,5 +147,5 @@ async getMarketAccount(publicKey) { | ||
}, market = web3_js_1.Keypair.generate(), collectFeeAdmin) { | ||
const bids = await this.createProgramAccount(payer, BooksideSpace); | ||
const asks = await this.createProgramAccount(payer, BooksideSpace); | ||
const eventHeap = await this.createProgramAccount(payer, EventHeapSpace); | ||
const [bidIx, bidsKeypair] = await this.createProgramAccountIx(payer, BooksideSpace); | ||
const [askIx, askKeypair] = await this.createProgramAccountIx(payer, BooksideSpace); | ||
const [eventHeapIx, eventHeapKeypair] = await this.createProgramAccountIx(payer, EventHeapSpace); | ||
const [marketAuthority] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('Market'), market.publicKey.toBuffer()], this.program.programId); | ||
@@ -148,6 +160,6 @@ const baseVault = (0, spl_token_1.getAssociatedTokenAddressSync)(baseMint, marketAuthority, true); | ||
marketAuthority, | ||
bids, | ||
asks, | ||
eventHeap, | ||
payer: payer.publicKey, | ||
bids: bidsKeypair.publicKey, | ||
asks: askKeypair.publicKey, | ||
eventHeap: eventHeapKeypair.publicKey, | ||
payer, | ||
marketBaseVault: baseVault, | ||
@@ -162,3 +174,3 @@ marketQuoteVault: quoteVault, | ||
oracleB, | ||
collectFeeAdmin: collectFeeAdmin != null ? collectFeeAdmin : payer.publicKey, | ||
collectFeeAdmin: collectFeeAdmin != null ? collectFeeAdmin : payer, | ||
openOrdersAdmin, | ||
@@ -171,6 +183,6 @@ consumeEventsAdmin, | ||
.instruction(); | ||
await this.sendAndConfirmTransaction([ix], { | ||
additionalSigners: [payer, market], | ||
}); | ||
return market.publicKey; | ||
return [ | ||
[bidIx, askIx, eventHeapIx, ix], | ||
[market, bidsKeypair, askKeypair, eventHeapKeypair], | ||
]; | ||
} | ||
@@ -177,0 +189,0 @@ // Book and EventHeap must be empty before closing a market. |
@@ -60,3 +60,3 @@ import { BN, Program, } from '@coral-xyz/anchor'; | ||
const tx = new Transaction().add(SystemProgram.createAccount({ | ||
fromPubkey: authority.publicKey, | ||
fromPubkey: authority, | ||
newAccountPubkey: address.publicKey, | ||
@@ -68,6 +68,18 @@ lamports, | ||
await this.sendAndConfirmTransaction(tx, { | ||
additionalSigners: [authority, address], | ||
additionalSigners: [address], | ||
}); | ||
return address.publicKey; | ||
} | ||
async createProgramAccountIx(authority, size) { | ||
const lamports = await this.connection.getMinimumBalanceForRentExemption(size); | ||
const address = Keypair.generate(); | ||
const ix = SystemProgram.createAccount({ | ||
fromPubkey: authority, | ||
newAccountPubkey: address.publicKey, | ||
lamports, | ||
space: size, | ||
programId: this.programId, | ||
}); | ||
return [ix, address]; | ||
} | ||
// Get the MarketAccount from the market publicKey | ||
@@ -131,5 +143,5 @@ async getMarketAccount(publicKey) { | ||
}, market = Keypair.generate(), collectFeeAdmin) { | ||
const bids = await this.createProgramAccount(payer, BooksideSpace); | ||
const asks = await this.createProgramAccount(payer, BooksideSpace); | ||
const eventHeap = await this.createProgramAccount(payer, EventHeapSpace); | ||
const [bidIx, bidsKeypair] = await this.createProgramAccountIx(payer, BooksideSpace); | ||
const [askIx, askKeypair] = await this.createProgramAccountIx(payer, BooksideSpace); | ||
const [eventHeapIx, eventHeapKeypair] = await this.createProgramAccountIx(payer, EventHeapSpace); | ||
const [marketAuthority] = PublicKey.findProgramAddressSync([Buffer.from('Market'), market.publicKey.toBuffer()], this.program.programId); | ||
@@ -144,6 +156,6 @@ const baseVault = getAssociatedTokenAddressSync(baseMint, marketAuthority, true); | ||
marketAuthority, | ||
bids, | ||
asks, | ||
eventHeap, | ||
payer: payer.publicKey, | ||
bids: bidsKeypair.publicKey, | ||
asks: askKeypair.publicKey, | ||
eventHeap: eventHeapKeypair.publicKey, | ||
payer, | ||
marketBaseVault: baseVault, | ||
@@ -158,3 +170,3 @@ marketQuoteVault: quoteVault, | ||
oracleB, | ||
collectFeeAdmin: collectFeeAdmin != null ? collectFeeAdmin : payer.publicKey, | ||
collectFeeAdmin: collectFeeAdmin != null ? collectFeeAdmin : payer, | ||
openOrdersAdmin, | ||
@@ -167,6 +179,6 @@ consumeEventsAdmin, | ||
.instruction(); | ||
await this.sendAndConfirmTransaction([ix], { | ||
additionalSigners: [payer, market], | ||
}); | ||
return market.publicKey; | ||
return [ | ||
[bidIx, askIx, eventHeapIx, ix], | ||
[market, bidsKeypair, askKeypair, eventHeapKeypair], | ||
]; | ||
} | ||
@@ -173,0 +185,0 @@ // Book and EventHeap must be empty before closing a market. |
@@ -5,3 +5,3 @@ /// <reference types="bn.js" /> | ||
import { type RawMint } from '@solana/spl-token'; | ||
import { type AccountInfo, type Commitment, type Connection, Keypair, PublicKey, type TransactionInstruction, type TransactionSignature } from '@solana/web3.js'; | ||
import { type AccountInfo, type Commitment, type Connection, Keypair, PublicKey, type Signer, type TransactionInstruction, type TransactionSignature } from '@solana/web3.js'; | ||
import { type OpenbookV2 } from './openbook_v2'; | ||
@@ -45,3 +45,4 @@ export type IdsSource = 'api' | 'static' | 'get-program-accounts'; | ||
sendAndConfirmTransaction(ixs: TransactionInstruction[], opts?: any): Promise<string>; | ||
createProgramAccount(authority: Keypair, size: number): Promise<PublicKey>; | ||
createProgramAccount(authority: PublicKey, size: number): Promise<PublicKey>; | ||
createProgramAccountIx(authority: PublicKey, size: number): Promise<[TransactionInstruction, Signer]>; | ||
getMarketAccount(publicKey: PublicKey): Promise<MarketAccount | null>; | ||
@@ -54,3 +55,3 @@ getOpenOrders(publicKey: PublicKey): Promise<OpenOrdersAccount | null>; | ||
getLeafNodes(bookside: BookSideAccount): LeafNode[]; | ||
createMarket(payer: Keypair, name: string, quoteMint: PublicKey, baseMint: PublicKey, quoteLotSize: BN, baseLotSize: BN, makerFee: BN, takerFee: BN, timeExpiry: BN, oracleA: PublicKey | null, oracleB: PublicKey | null, openOrdersAdmin: PublicKey | null, consumeEventsAdmin: PublicKey | null, closeMarketAdmin: PublicKey | null, oracleConfigParams?: OracleConfigParams, market?: Keypair, collectFeeAdmin?: PublicKey): Promise<PublicKey>; | ||
createMarket(payer: PublicKey, name: string, quoteMint: PublicKey, baseMint: PublicKey, quoteLotSize: BN, baseLotSize: BN, makerFee: BN, takerFee: BN, timeExpiry: BN, oracleA: PublicKey | null, oracleB: PublicKey | null, openOrdersAdmin: PublicKey | null, consumeEventsAdmin: PublicKey | null, closeMarketAdmin: PublicKey | null, oracleConfigParams?: OracleConfigParams, market?: Keypair, collectFeeAdmin?: PublicKey): Promise<[TransactionInstruction[], Signer[]]>; | ||
closeMarket(marketPublicKey: PublicKey, market: MarketAccount, solDestination: PublicKey, closeMarketAdmin?: Keypair | null): Promise<TransactionSignature>; | ||
@@ -57,0 +58,0 @@ findOpenOrdersIndexer(owner?: PublicKey): PublicKey; |
{ | ||
"name": "@openbook-dex/openbook-v2", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"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
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
630360
16774