@openbook-dex/openbook-v2
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -69,2 +69,4 @@ /// <reference types="bn.js" /> | ||
cancelOrderByClientId(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, clientOrderId: BN, openOrdersDelegate?: Keypair): Promise<TransactionSignature>; | ||
closeOpenOrdersIndexer(owner: Keypair, market: MarketAccount, openOrdersIndexer?: PublicKey): Promise<TransactionSignature>; | ||
closeOpenOrdersAccount(payer: Keypair, owner: Keypair | undefined, openOrdersPublicKey: PublicKey, market: MarketAccount, solDestination?: PublicKey, openOrdersIndexer?: PublicKey): Promise<TransactionSignature>; | ||
consumeEvents(marketPublicKey: PublicKey, market: MarketAccount, limit: BN, remainingAccounts: PublicKey[]): Promise<TransactionSignature>; | ||
@@ -71,0 +73,0 @@ consumeGivenEvents(marketPublicKey: PublicKey, market: MarketAccount, slots: BN[], remainingAccounts: PublicKey[]): Promise<TransactionSignature>; |
@@ -489,2 +489,52 @@ "use strict"; | ||
} | ||
async closeOpenOrdersIndexer(owner, market, openOrdersIndexer) { | ||
if (openOrdersIndexer == null) { | ||
openOrdersIndexer = this.findOpenOrdersIndexer(owner.publicKey); | ||
} | ||
if (openOrdersIndexer !== null) { | ||
const ix = await this.program.methods | ||
.closeOpenOrdersIndexer() | ||
.accounts({ | ||
owner: owner.publicKey, | ||
openOrdersIndexer: market.asks, | ||
solDestination: market.bids, | ||
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID, | ||
}) | ||
.instruction(); | ||
const additionalSigners = []; | ||
if (owner.publicKey !== this.walletPk) { | ||
additionalSigners.push(owner); | ||
} | ||
return await this.sendAndConfirmTransaction([ix], { | ||
additionalSigners, | ||
}); | ||
} | ||
throw new Error('No open order indexer for the specified owner'); | ||
} | ||
async closeOpenOrdersAccount(payer, owner = payer, openOrdersPublicKey, market, solDestination = this.walletPk, openOrdersIndexer) { | ||
if (openOrdersIndexer == null) { | ||
openOrdersIndexer = this.findOpenOrdersIndexer(owner.publicKey); | ||
} | ||
if (openOrdersIndexer !== null) { | ||
const ix = await this.program.methods | ||
.closeOpenOrdersAccount() | ||
.accounts({ | ||
payer: payer.publicKey, | ||
owner: owner.publicKey, | ||
openOrdersIndexer, | ||
openOrdersAccount: openOrdersPublicKey, | ||
solDestination, | ||
systemProgram: web3_js_1.SystemProgram.programId, | ||
}) | ||
.instruction(); | ||
const additionalSigners = [payer]; | ||
if (owner !== payer) { | ||
additionalSigners.push(owner); | ||
} | ||
return await this.sendAndConfirmTransaction([ix], { | ||
additionalSigners, | ||
}); | ||
} | ||
throw new Error('No open order indexer for the specified owner'); | ||
} | ||
// Use getAccountsToConsume as a helper | ||
@@ -491,0 +541,0 @@ async consumeEvents(marketPublicKey, market, limit, remainingAccounts) { |
/// <reference types="node" /> | ||
/// <reference types="bn.js" /> | ||
import { PublicKey, type Connection, type AccountInfo } from '@solana/web3.js'; | ||
import { type Provider } from '@coral-xyz/anchor'; | ||
import { type MarketAccount } from './client'; | ||
import { type Provider, BN } from '@coral-xyz/anchor'; | ||
export declare function findAccountsByMints(connection: Connection, baseMintAddress: PublicKey, quoteMintAddress: PublicKey, programId: PublicKey): Promise<Array<{ | ||
@@ -16,2 +18,10 @@ publicKey: PublicKey; | ||
export declare function findAllMarkets(connection: Connection, programId?: PublicKey, provider?: Provider): Promise<Market[]>; | ||
export declare function uiPriceToLots(market: MarketAccount, price: number): BN; | ||
export declare function uiBaseToLots(market: MarketAccount, quantity: number): BN; | ||
export declare function uiQuoteToLots(market: MarketAccount, uiQuote: number): BN; | ||
export declare function priceLotsToNative(market: MarketAccount, price: BN): BN; | ||
export declare function priceLotsToUi(market: MarketAccount, price: BN): number; | ||
export declare function priceNativeToUi(market: MarketAccount, price: number): number; | ||
export declare function baseLotsToUi(market: MarketAccount, quantity: BN): number; | ||
export declare function quoteLotsToUi(quantity: BN): number; | ||
export {}; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findAllMarkets = exports.findAccountsByMints = void 0; | ||
exports.quoteLotsToUi = exports.baseLotsToUi = exports.priceNativeToUi = exports.priceLotsToUi = exports.priceLotsToNative = exports.uiQuoteToLots = exports.uiBaseToLots = exports.uiPriceToLots = exports.findAllMarkets = exports.findAccountsByMints = void 0; | ||
const web3_js_1 = require("@solana/web3.js"); | ||
const client_1 = require("./client"); | ||
const anchor_1 = require("@coral-xyz/anchor"); | ||
const utils_1 = require("./utils/utils"); | ||
const big_js_1 = __importDefault(require("big.js")); | ||
const openbook_v2_1 = require("./openbook_v2"); | ||
@@ -80,1 +85,52 @@ const BATCH_TX_SIZE = 50; | ||
exports.findAllMarkets = findAllMarkets; | ||
function priceLotsToUiConverter(market) { | ||
return new big_js_1.default(10) | ||
.pow(market.baseDecimals - utils_1.QUOTE_DECIMALS) | ||
.mul(new big_js_1.default(this.quoteLotSize.toString())) | ||
.div(new big_js_1.default(this.baseLotSize.toString())) | ||
.toNumber(); | ||
} | ||
function baseLotsToUiConverter(market) { | ||
return new big_js_1.default(this.baseLotSize.toString()) | ||
.div(new big_js_1.default(10).pow(market.baseDecimals)) | ||
.toNumber(); | ||
} | ||
function quoteLotsToUiConverter() { | ||
return new big_js_1.default(this.quoteLotSize.toString()) | ||
.div(new big_js_1.default(10).pow(utils_1.QUOTE_DECIMALS)) | ||
.toNumber(); | ||
} | ||
function uiPriceToLots(market, price) { | ||
return (0, utils_1.toNative)(price, utils_1.QUOTE_DECIMALS) | ||
.mul(market.baseLotSize) | ||
.div(market.quoteLotSize.mul(new anchor_1.BN(Math.pow(10, market.baseDecimals)))); | ||
} | ||
exports.uiPriceToLots = uiPriceToLots; | ||
function uiBaseToLots(market, quantity) { | ||
return (0, utils_1.toNative)(quantity, market.baseDecimals).div(market.baseLotSize); | ||
} | ||
exports.uiBaseToLots = uiBaseToLots; | ||
function uiQuoteToLots(market, uiQuote) { | ||
return (0, utils_1.toNative)(uiQuote, utils_1.QUOTE_DECIMALS).div(market.quoteLotSize); | ||
} | ||
exports.uiQuoteToLots = uiQuoteToLots; | ||
function priceLotsToNative(market, price) { | ||
return price.mul(market.quoteLotSize).div(market.baseLotSize); | ||
} | ||
exports.priceLotsToNative = priceLotsToNative; | ||
function priceLotsToUi(market, price) { | ||
return parseFloat(price.toString()) * priceLotsToUiConverter(market); | ||
} | ||
exports.priceLotsToUi = priceLotsToUi; | ||
function priceNativeToUi(market, price) { | ||
return (0, utils_1.toUiDecimals)(price, utils_1.QUOTE_DECIMALS - market.baseDecimals); | ||
} | ||
exports.priceNativeToUi = priceNativeToUi; | ||
function baseLotsToUi(market, quantity) { | ||
return parseFloat(quantity.toString()) * baseLotsToUiConverter(market); | ||
} | ||
exports.baseLotsToUi = baseLotsToUi; | ||
function quoteLotsToUi(quantity) { | ||
return parseFloat(quantity.toString()) * quoteLotsToUiConverter(); | ||
} | ||
exports.quoteLotsToUi = quoteLotsToUi; |
@@ -0,1 +1,3 @@ | ||
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
import BN from 'bn.js'; | ||
export declare const Side: { | ||
@@ -37,1 +39,22 @@ Bid: { | ||
}; | ||
export declare const U64_MAX_BN: BN; | ||
export declare const I64_MAX_BN: BN; | ||
export declare function bpsToDecimal(bps: number): number; | ||
export declare function percentageToDecimal(percentage: number): number; | ||
export declare function toNative(uiAmount: number, decimals: number): BN; | ||
export declare function toUiDecimals(nativeAmount: number, decimals: number): number; | ||
export declare const QUOTE_DECIMALS = 6; | ||
export declare function toUiDecimalsForQuote(nativeAmount: number): number; | ||
/** | ||
* Get the address of the associated token account for a given mint and owner | ||
* | ||
* @param mint Token mint account | ||
* @param owner Owner of the new account | ||
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program Derived Address) | ||
* @param programId SPL Token program account | ||
* @param associatedTokenProgramId SPL Associated Token program account | ||
* | ||
* @return Address of the associated token account | ||
*/ | ||
export declare function getAssociatedTokenAddress(mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, programId?: PublicKey, associatedTokenProgramId?: PublicKey): Promise<PublicKey>; | ||
export declare function createAssociatedTokenAccountIdempotentInstruction(payer: PublicKey, owner: PublicKey, mint: PublicKey): Promise<TransactionInstruction>; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SelfTradeBehavior = exports.OrderType = exports.Side = void 0; | ||
exports.createAssociatedTokenAccountIdempotentInstruction = exports.getAssociatedTokenAddress = exports.toUiDecimalsForQuote = exports.QUOTE_DECIMALS = exports.toUiDecimals = exports.toNative = exports.percentageToDecimal = exports.bpsToDecimal = exports.I64_MAX_BN = exports.U64_MAX_BN = exports.SelfTradeBehavior = exports.OrderType = exports.Side = void 0; | ||
const web3_js_1 = require("@solana/web3.js"); | ||
const bn_js_1 = __importDefault(require("bn.js")); | ||
const spl_token_1 = require("@solana/spl-token"); | ||
exports.Side = { | ||
@@ -20,1 +26,69 @@ Bid: { bid: {} }, | ||
}; | ||
/// | ||
/// numeric helpers | ||
/// | ||
exports.U64_MAX_BN = new bn_js_1.default('18446744073709551615'); | ||
exports.I64_MAX_BN = new bn_js_1.default('9223372036854775807').toTwos(64); | ||
function bpsToDecimal(bps) { | ||
return bps / 10000; | ||
} | ||
exports.bpsToDecimal = bpsToDecimal; | ||
function percentageToDecimal(percentage) { | ||
return percentage / 100; | ||
} | ||
exports.percentageToDecimal = percentageToDecimal; | ||
function toNative(uiAmount, decimals) { | ||
return new bn_js_1.default((uiAmount * Math.pow(10, decimals)).toFixed(0)); | ||
} | ||
exports.toNative = toNative; | ||
function toUiDecimals(nativeAmount, decimals) { | ||
return nativeAmount / Math.pow(10, decimals); | ||
} | ||
exports.toUiDecimals = toUiDecimals; | ||
exports.QUOTE_DECIMALS = 6; | ||
function toUiDecimalsForQuote(nativeAmount) { | ||
return toUiDecimals(nativeAmount, exports.QUOTE_DECIMALS); | ||
} | ||
exports.toUiDecimalsForQuote = toUiDecimalsForQuote; | ||
/// | ||
/// | ||
/// web3js extensions | ||
/// | ||
/** | ||
* Get the address of the associated token account for a given mint and owner | ||
* | ||
* @param mint Token mint account | ||
* @param owner Owner of the new account | ||
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program Derived Address) | ||
* @param programId SPL Token program account | ||
* @param associatedTokenProgramId SPL Associated Token program account | ||
* | ||
* @return Address of the associated token account | ||
*/ | ||
async function getAssociatedTokenAddress(mint, owner, allowOwnerOffCurve = true, programId = spl_token_1.TOKEN_PROGRAM_ID, associatedTokenProgramId = spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID) { | ||
if (!allowOwnerOffCurve && !web3_js_1.PublicKey.isOnCurve(owner.toBuffer())) | ||
throw new Error('TokenOwnerOffCurve!'); | ||
const [address] = await web3_js_1.PublicKey.findProgramAddress([owner.toBuffer(), programId.toBuffer(), mint.toBuffer()], associatedTokenProgramId); | ||
return address; | ||
} | ||
exports.getAssociatedTokenAddress = getAssociatedTokenAddress; | ||
async function createAssociatedTokenAccountIdempotentInstruction(payer, owner, mint) { | ||
const account = await getAssociatedTokenAddress(mint, owner); | ||
return new web3_js_1.TransactionInstruction({ | ||
keys: [ | ||
{ pubkey: payer, isSigner: true, isWritable: true }, | ||
{ pubkey: account, isSigner: false, isWritable: true }, | ||
{ pubkey: owner, isSigner: false, isWritable: false }, | ||
{ pubkey: mint, isSigner: false, isWritable: false }, | ||
{ | ||
pubkey: web3_js_1.SystemProgram.programId, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, | ||
], | ||
programId: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, | ||
data: Buffer.from([0x1]), | ||
}); | ||
} | ||
exports.createAssociatedTokenAccountIdempotentInstruction = createAssociatedTokenAccountIdempotentInstruction; |
@@ -485,2 +485,52 @@ import { BN, Program, } from '@coral-xyz/anchor'; | ||
} | ||
async closeOpenOrdersIndexer(owner, market, openOrdersIndexer) { | ||
if (openOrdersIndexer == null) { | ||
openOrdersIndexer = this.findOpenOrdersIndexer(owner.publicKey); | ||
} | ||
if (openOrdersIndexer !== null) { | ||
const ix = await this.program.methods | ||
.closeOpenOrdersIndexer() | ||
.accounts({ | ||
owner: owner.publicKey, | ||
openOrdersIndexer: market.asks, | ||
solDestination: market.bids, | ||
tokenProgram: TOKEN_PROGRAM_ID, | ||
}) | ||
.instruction(); | ||
const additionalSigners = []; | ||
if (owner.publicKey !== this.walletPk) { | ||
additionalSigners.push(owner); | ||
} | ||
return await this.sendAndConfirmTransaction([ix], { | ||
additionalSigners, | ||
}); | ||
} | ||
throw new Error('No open order indexer for the specified owner'); | ||
} | ||
async closeOpenOrdersAccount(payer, owner = payer, openOrdersPublicKey, market, solDestination = this.walletPk, openOrdersIndexer) { | ||
if (openOrdersIndexer == null) { | ||
openOrdersIndexer = this.findOpenOrdersIndexer(owner.publicKey); | ||
} | ||
if (openOrdersIndexer !== null) { | ||
const ix = await this.program.methods | ||
.closeOpenOrdersAccount() | ||
.accounts({ | ||
payer: payer.publicKey, | ||
owner: owner.publicKey, | ||
openOrdersIndexer, | ||
openOrdersAccount: openOrdersPublicKey, | ||
solDestination, | ||
systemProgram: SystemProgram.programId, | ||
}) | ||
.instruction(); | ||
const additionalSigners = [payer]; | ||
if (owner !== payer) { | ||
additionalSigners.push(owner); | ||
} | ||
return await this.sendAndConfirmTransaction([ix], { | ||
additionalSigners, | ||
}); | ||
} | ||
throw new Error('No open order indexer for the specified owner'); | ||
} | ||
// Use getAccountsToConsume as a helper | ||
@@ -487,0 +537,0 @@ async consumeEvents(marketPublicKey, market, limit, remainingAccounts) { |
import { PublicKey, } from '@solana/web3.js'; | ||
import { OPENBOOK_PROGRAM_ID, getFilteredProgramAccounts } from './client'; | ||
import { utils, Program, getProvider } from '@coral-xyz/anchor'; | ||
import { OPENBOOK_PROGRAM_ID, getFilteredProgramAccounts, } from './client'; | ||
import { utils, Program, getProvider, BN, } from '@coral-xyz/anchor'; | ||
import { QUOTE_DECIMALS, toNative, toUiDecimals } from './utils/utils'; | ||
import Big from 'big.js'; | ||
import { IDL } from './openbook_v2'; | ||
@@ -75,1 +77,44 @@ const BATCH_TX_SIZE = 50; | ||
} | ||
function priceLotsToUiConverter(market) { | ||
return new Big(10) | ||
.pow(market.baseDecimals - QUOTE_DECIMALS) | ||
.mul(new Big(this.quoteLotSize.toString())) | ||
.div(new Big(this.baseLotSize.toString())) | ||
.toNumber(); | ||
} | ||
function baseLotsToUiConverter(market) { | ||
return new Big(this.baseLotSize.toString()) | ||
.div(new Big(10).pow(market.baseDecimals)) | ||
.toNumber(); | ||
} | ||
function quoteLotsToUiConverter() { | ||
return new Big(this.quoteLotSize.toString()) | ||
.div(new Big(10).pow(QUOTE_DECIMALS)) | ||
.toNumber(); | ||
} | ||
export function uiPriceToLots(market, price) { | ||
return toNative(price, QUOTE_DECIMALS) | ||
.mul(market.baseLotSize) | ||
.div(market.quoteLotSize.mul(new BN(Math.pow(10, market.baseDecimals)))); | ||
} | ||
export function uiBaseToLots(market, quantity) { | ||
return toNative(quantity, market.baseDecimals).div(market.baseLotSize); | ||
} | ||
export function uiQuoteToLots(market, uiQuote) { | ||
return toNative(uiQuote, QUOTE_DECIMALS).div(market.quoteLotSize); | ||
} | ||
export function priceLotsToNative(market, price) { | ||
return price.mul(market.quoteLotSize).div(market.baseLotSize); | ||
} | ||
export function priceLotsToUi(market, price) { | ||
return parseFloat(price.toString()) * priceLotsToUiConverter(market); | ||
} | ||
export function priceNativeToUi(market, price) { | ||
return toUiDecimals(price, QUOTE_DECIMALS - market.baseDecimals); | ||
} | ||
export function baseLotsToUi(market, quantity) { | ||
return parseFloat(quantity.toString()) * baseLotsToUiConverter(market); | ||
} | ||
export function quoteLotsToUi(quantity) { | ||
return parseFloat(quantity.toString()) * quoteLotsToUiConverter(); | ||
} |
@@ -0,1 +1,4 @@ | ||
import { PublicKey, SystemProgram, TransactionInstruction, } from '@solana/web3.js'; | ||
import BN from 'bn.js'; | ||
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, } from '@solana/spl-token'; | ||
export const Side = { | ||
@@ -17,1 +20,62 @@ Bid: { bid: {} }, | ||
}; | ||
/// | ||
/// numeric helpers | ||
/// | ||
export const U64_MAX_BN = new BN('18446744073709551615'); | ||
export const I64_MAX_BN = new BN('9223372036854775807').toTwos(64); | ||
export function bpsToDecimal(bps) { | ||
return bps / 10000; | ||
} | ||
export function percentageToDecimal(percentage) { | ||
return percentage / 100; | ||
} | ||
export function toNative(uiAmount, decimals) { | ||
return new BN((uiAmount * Math.pow(10, decimals)).toFixed(0)); | ||
} | ||
export function toUiDecimals(nativeAmount, decimals) { | ||
return nativeAmount / Math.pow(10, decimals); | ||
} | ||
export const QUOTE_DECIMALS = 6; | ||
export function toUiDecimalsForQuote(nativeAmount) { | ||
return toUiDecimals(nativeAmount, QUOTE_DECIMALS); | ||
} | ||
/// | ||
/// | ||
/// web3js extensions | ||
/// | ||
/** | ||
* Get the address of the associated token account for a given mint and owner | ||
* | ||
* @param mint Token mint account | ||
* @param owner Owner of the new account | ||
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program Derived Address) | ||
* @param programId SPL Token program account | ||
* @param associatedTokenProgramId SPL Associated Token program account | ||
* | ||
* @return Address of the associated token account | ||
*/ | ||
export async function getAssociatedTokenAddress(mint, owner, allowOwnerOffCurve = true, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) { | ||
if (!allowOwnerOffCurve && !PublicKey.isOnCurve(owner.toBuffer())) | ||
throw new Error('TokenOwnerOffCurve!'); | ||
const [address] = await PublicKey.findProgramAddress([owner.toBuffer(), programId.toBuffer(), mint.toBuffer()], associatedTokenProgramId); | ||
return address; | ||
} | ||
export async function createAssociatedTokenAccountIdempotentInstruction(payer, owner, mint) { | ||
const account = await getAssociatedTokenAddress(mint, owner); | ||
return new TransactionInstruction({ | ||
keys: [ | ||
{ pubkey: payer, isSigner: true, isWritable: true }, | ||
{ pubkey: account, isSigner: false, isWritable: true }, | ||
{ pubkey: owner, isSigner: false, isWritable: false }, | ||
{ pubkey: mint, isSigner: false, isWritable: false }, | ||
{ | ||
pubkey: SystemProgram.programId, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, | ||
], | ||
programId: ASSOCIATED_TOKEN_PROGRAM_ID, | ||
data: Buffer.from([0x1]), | ||
}); | ||
} |
@@ -69,2 +69,4 @@ /// <reference types="bn.js" /> | ||
cancelOrderByClientId(openOrdersPublicKey: PublicKey, openOrdersAccount: OpenOrdersAccount, market: MarketAccount, clientOrderId: BN, openOrdersDelegate?: Keypair): Promise<TransactionSignature>; | ||
closeOpenOrdersIndexer(owner: Keypair, market: MarketAccount, openOrdersIndexer?: PublicKey): Promise<TransactionSignature>; | ||
closeOpenOrdersAccount(payer: Keypair, owner: Keypair | undefined, openOrdersPublicKey: PublicKey, market: MarketAccount, solDestination?: PublicKey, openOrdersIndexer?: PublicKey): Promise<TransactionSignature>; | ||
consumeEvents(marketPublicKey: PublicKey, market: MarketAccount, limit: BN, remainingAccounts: PublicKey[]): Promise<TransactionSignature>; | ||
@@ -71,0 +73,0 @@ consumeGivenEvents(marketPublicKey: PublicKey, market: MarketAccount, slots: BN[], remainingAccounts: PublicKey[]): Promise<TransactionSignature>; |
/// <reference types="node" /> | ||
/// <reference types="bn.js" /> | ||
import { PublicKey, type Connection, type AccountInfo } from '@solana/web3.js'; | ||
import { type Provider } from '@coral-xyz/anchor'; | ||
import { type MarketAccount } from './client'; | ||
import { type Provider, BN } from '@coral-xyz/anchor'; | ||
export declare function findAccountsByMints(connection: Connection, baseMintAddress: PublicKey, quoteMintAddress: PublicKey, programId: PublicKey): Promise<Array<{ | ||
@@ -16,3 +18,11 @@ publicKey: PublicKey; | ||
export declare function findAllMarkets(connection: Connection, programId?: PublicKey, provider?: Provider): Promise<Market[]>; | ||
export declare function uiPriceToLots(market: MarketAccount, price: number): BN; | ||
export declare function uiBaseToLots(market: MarketAccount, quantity: number): BN; | ||
export declare function uiQuoteToLots(market: MarketAccount, uiQuote: number): BN; | ||
export declare function priceLotsToNative(market: MarketAccount, price: BN): BN; | ||
export declare function priceLotsToUi(market: MarketAccount, price: BN): number; | ||
export declare function priceNativeToUi(market: MarketAccount, price: number): number; | ||
export declare function baseLotsToUi(market: MarketAccount, quantity: BN): number; | ||
export declare function quoteLotsToUi(quantity: BN): number; | ||
export {}; | ||
//# sourceMappingURL=market.d.ts.map |
@@ -0,1 +1,3 @@ | ||
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
import BN from 'bn.js'; | ||
export declare const Side: { | ||
@@ -37,2 +39,23 @@ Bid: { | ||
}; | ||
export declare const U64_MAX_BN: BN; | ||
export declare const I64_MAX_BN: BN; | ||
export declare function bpsToDecimal(bps: number): number; | ||
export declare function percentageToDecimal(percentage: number): number; | ||
export declare function toNative(uiAmount: number, decimals: number): BN; | ||
export declare function toUiDecimals(nativeAmount: number, decimals: number): number; | ||
export declare const QUOTE_DECIMALS = 6; | ||
export declare function toUiDecimalsForQuote(nativeAmount: number): number; | ||
/** | ||
* Get the address of the associated token account for a given mint and owner | ||
* | ||
* @param mint Token mint account | ||
* @param owner Owner of the new account | ||
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program Derived Address) | ||
* @param programId SPL Token program account | ||
* @param associatedTokenProgramId SPL Associated Token program account | ||
* | ||
* @return Address of the associated token account | ||
*/ | ||
export declare function getAssociatedTokenAddress(mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, programId?: PublicKey, associatedTokenProgramId?: PublicKey): Promise<PublicKey>; | ||
export declare function createAssociatedTokenAccountIdempotentInstruction(payer: PublicKey, owner: PublicKey, mint: PublicKey): Promise<TransactionInstruction>; | ||
//# sourceMappingURL=utils.d.ts.map |
{ | ||
"name": "@openbook-dex/openbook-v2", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "Typescript Client for openbook-v2 program.", | ||
@@ -35,7 +35,6 @@ "repository": "https://github.com/openbook-dex/openbook-v2/", | ||
"@solana/spl-token": "0.3.8", | ||
"@solana/web3.js": "^1.77.3" | ||
"@solana/web3.js": "^1.77.3", | ||
"big.js": "^6.2.1" | ||
}, | ||
"devDependencies": { | ||
"eslint-config-prettier": "^8.10.0", | ||
"fs": "^0.0.1-security", | ||
"@types/bn.js": "^5.1.0", | ||
@@ -47,2 +46,3 @@ "@types/chai": "^4.3.0", | ||
"eslint": "^8.0.1", | ||
"eslint-config-prettier": "^8.10.0", | ||
"eslint-config-standard-with-typescript": "^37.0.0", | ||
@@ -52,2 +52,3 @@ "eslint-plugin-import": "^2.25.2", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"fs": "^0.0.1-security", | ||
"mocha": "^9.0.3", | ||
@@ -54,0 +55,0 @@ "prettier": "^2.6.2", |
Sorry, the diff of this file is not supported yet
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
616615
16503
4
+ Addedbig.js@^6.2.1
+ Addedbig.js@6.2.2(transitive)
+ Addedjayson@4.1.3(transitive)
- Removedjayson@4.1.2(transitive)