///
import { Slab } from './slab';
import BN from 'bn.js';
import { Account, AccountInfo, Commitment, Connection, PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js';
export declare const _MARKET_STAT_LAYOUT_V1: any;
export declare const MARKET_STATE_LAYOUT_V2: any;
export declare const MARKET_STATE_LAYOUT_V3: any;
export declare class Market {
private _decoded;
private _baseSplTokenDecimals;
private _quoteSplTokenDecimals;
private _skipPreflight;
private _commitment;
private _programId;
private _openOrdersAccountsCache;
private _layoutOverride?;
private _feeDiscountKeysCache;
constructor(decoded: any, baseMintDecimals: number, quoteMintDecimals: number, options: MarketOptions | undefined, programId: PublicKey, layoutOverride?: any);
static getLayout(programId: PublicKey): any;
static findAccountsByMints(connection: Connection, baseMintAddress: PublicKey, quoteMintAddress: PublicKey, programId: PublicKey): Promise<{
publicKey: PublicKey;
accountInfo: AccountInfo;
}[]>;
static load(connection: Connection, address: PublicKey, options: MarketOptions | undefined, programId: PublicKey, layoutOverride?: any): Promise;
get programId(): PublicKey;
get address(): PublicKey;
get publicKey(): PublicKey;
get baseMintAddress(): PublicKey;
get quoteMintAddress(): PublicKey;
get bidsAddress(): PublicKey;
get asksAddress(): PublicKey;
get decoded(): any;
loadBids(connection: Connection): Promise;
loadAsks(connection: Connection): Promise;
loadOrdersForOwner(connection: Connection, ownerAddress: PublicKey, cacheDurationMs?: number): Promise;
filterForOpenOrders(bids: Orderbook, asks: Orderbook, openOrdersAccounts: OpenOrders[]): Order[];
findBaseTokenAccountsForOwner(connection: Connection, ownerAddress: PublicKey, includeUnwrappedSol?: boolean): Promise;
}>>;
getTokenAccountsByOwnerForMint(connection: Connection, ownerAddress: PublicKey, mintAddress: PublicKey): Promise;
}>>;
findQuoteTokenAccountsForOwner(connection: Connection, ownerAddress: PublicKey, includeUnwrappedSol?: boolean): Promise<{
pubkey: PublicKey;
account: AccountInfo;
}[]>;
findOpenOrdersAccountsForOwner(connection: Connection, ownerAddress: PublicKey, cacheDurationMs?: number): Promise;
replaceOrders(connection: Connection, accounts: OrderParamsAccounts, orders: OrderParamsBase[], cacheDurationMs?: number): Promise;
placeOrder(connection: Connection, { owner, payer, side, price, size, orderType, clientId, openOrdersAddressKey, openOrdersAccount, feeDiscountPubkey, maxTs, replaceIfExists, }: OrderParams): Promise;
getSplTokenBalanceFromAccountInfo(accountInfo: AccountInfo, decimals: number): number;
get supportsSrmFeeDiscounts(): boolean;
get supportsReferralFees(): boolean;
get usesRequestQueue(): boolean;
findFeeDiscountKeys(connection: Connection, ownerAddress: PublicKey, cacheDurationMs?: number): Promise>;
findBestFeeDiscountKey(connection: Connection, ownerAddress: PublicKey, cacheDurationMs?: number): Promise<{
pubkey: PublicKey | null;
feeTier: number;
}>;
makePlaceOrderTransaction(connection: Connection, { owner, payer, side, price, size, orderType, clientId, openOrdersAddressKey, openOrdersAccount, feeDiscountPubkey, selfTradeBehavior, maxTs, replaceIfExists, }: OrderParams, cacheDurationMs?: number, feeDiscountPubkeyCacheDurationMs?: number): Promise<{
transaction: Transaction;
signers: Account[];
payer: T;
}>;
makePlaceOrderInstruction(connection: Connection, params: OrderParams): TransactionInstruction;
makeNewOrderV3Instruction(params: OrderParams): TransactionInstruction;
makeReplaceOrdersByClientIdsInstruction(accounts: OrderParamsAccounts, orders: OrderParamsBase[]): TransactionInstruction;
private _sendTransaction;
cancelOrderByClientId(connection: Connection, owner: Account, openOrders: PublicKey, clientId: BN): Promise;
cancelOrdersByClientIds(connection: Connection, owner: Account, openOrders: PublicKey, clientIds: BN[]): Promise;
makeCancelOrderByClientIdTransaction(connection: Connection, owner: PublicKey, openOrders: PublicKey, clientId: BN): Promise;
makeCancelOrdersByClientIdsTransaction(connection: Connection, owner: PublicKey, openOrders: PublicKey, clientIds: BN[]): Promise;
cancelOrder(connection: Connection, owner: Account, order: Order): Promise;
makeCancelOrderTransaction(connection: Connection, owner: PublicKey, order: Order): Promise;
makeCancelOrderInstruction(connection: Connection, owner: PublicKey, order: Order): TransactionInstruction;
makeConsumeEventsInstruction(openOrdersAccounts: Array, limit: number): TransactionInstruction;
makeConsumeEventsPermissionedInstruction(openOrdersAccounts: Array, limit: number): TransactionInstruction;
settleFunds(connection: Connection, owner: Account, openOrders: OpenOrders, baseWallet: PublicKey, quoteWallet: PublicKey, referrerQuoteWallet?: PublicKey | null): Promise;
makeSettleFundsTransaction(connection: Connection, openOrders: OpenOrders, baseWallet: PublicKey, quoteWallet: PublicKey, referrerQuoteWallet?: PublicKey | null): Promise<{
transaction: Transaction;
signers: Account[];
payer: PublicKey;
}>;
matchOrders(connection: Connection, feePayer: Account, limit: number): Promise;
makeMatchOrdersTransaction(limit: number): Transaction;
loadRequestQueue(connection: Connection): Promise;
loadEventQueue(connection: Connection): Promise;
loadFills(connection: Connection, limit?: number): Promise;
parseFillEvent(event: any): any;
private get _baseSplTokenMultiplier();
private get _quoteSplTokenMultiplier();
priceLotsToNumber(price: BN): number;
priceNumberToLots(price: number): BN;
baseSplSizeToNumber(size: BN): number;
quoteSplSizeToNumber(size: BN): number;
baseSizeLotsToNumber(size: BN): number;
baseSizeNumberToLots(size: number): BN;
quoteSizeLotsToNumber(size: BN): number;
quoteSizeNumberToLots(size: number): BN;
get minOrderSize(): number;
get tickSize(): number;
}
export interface MarketOptions {
skipPreflight?: boolean;
commitment?: Commitment;
}
export interface OrderParamsBase {
side: 'buy' | 'sell';
price: number;
size: number;
orderType?: 'limit' | 'ioc' | 'postOnly';
clientId?: BN;
selfTradeBehavior?: 'decrementTake' | 'cancelProvide' | 'abortTransaction' | undefined;
maxTs?: number | null;
}
export interface OrderParamsAccounts {
owner: T;
payer: PublicKey;
openOrdersAddressKey?: PublicKey;
openOrdersAccount?: Account;
feeDiscountPubkey?: PublicKey | null;
programId?: PublicKey;
}
export interface OrderParams extends OrderParamsBase, OrderParamsAccounts {
replaceIfExists?: boolean;
}
export declare const _OPEN_ORDERS_LAYOUT_V1: any;
export declare const _OPEN_ORDERS_LAYOUT_V2: any;
export declare class OpenOrders {
private _programId;
address: PublicKey;
market: PublicKey;
owner: PublicKey;
baseTokenFree: BN;
baseTokenTotal: BN;
quoteTokenFree: BN;
quoteTokenTotal: BN;
freeSlotBits: BN;
isBidBits: BN;
orders: BN[];
clientIds: BN[];
constructor(address: PublicKey, decoded: any, programId: PublicKey);
static getLayout(programId: PublicKey): any;
static findForOwner(connection: Connection, ownerAddress: PublicKey, programId: PublicKey): Promise;
static findForMarketAndOwner(connection: Connection, marketAddress: PublicKey, ownerAddress: PublicKey, programId: PublicKey): Promise;
static load(connection: Connection, address: PublicKey, programId: PublicKey): Promise;
static fromAccountInfo(address: PublicKey, accountInfo: AccountInfo, programId: PublicKey): OpenOrders;
static makeCreateAccountTransaction(connection: Connection, marketAddress: PublicKey, ownerAddress: PublicKey, newAccountAddress: PublicKey, programId: PublicKey): Promise;
get publicKey(): PublicKey;
}
export declare const ORDERBOOK_LAYOUT: any;
export declare class Orderbook {
market: Market;
isBids: boolean;
slab: Slab;
constructor(market: Market, accountFlags: any, slab: Slab);
static get LAYOUT(): any;
static decode(market: Market, buffer: Buffer): Orderbook;
getL2(depth: number): [number, number, BN, BN][];
[Symbol.iterator](): Generator;
items(descending?: boolean): Generator;
}
export interface Order {
orderId: BN;
openOrdersAddress: PublicKey;
openOrdersSlot: number;
price: number;
priceLots: BN;
size: number;
feeTier: number;
sizeLots: BN;
side: 'buy' | 'sell';
clientId?: BN;
}
export declare function getMintDecimals(connection: Connection, mint: PublicKey): Promise;
//# sourceMappingURL=market.d.ts.map