UNPKG

@cks-systems/manifest-sdk

Version:
126 lines 4.07 kB
import { Connection, PublicKey } from '@solana/web3.js'; import { bignum } from '@metaplex-foundation/beet'; import { OrderType } from './manifest'; /** * All data stored on a wrapper account. */ export interface WrapperData { /** Public key for the trader that owns this wrapper. */ trader: PublicKey; /** Array of market infos that have been parsed. */ marketInfos: WrapperMarketInfo[]; } /** * Parsed market info on a wrapper. Accurate to the last sync. */ export interface WrapperMarketInfo { /** Public key for market. */ market: PublicKey; /** Base balance in atoms. */ baseBalanceAtoms: bignum; /** Quote balance in atoms. */ quoteBalanceAtoms: bignum; /** Quote volume in atoms. */ quoteVolumeAtoms: bignum; /** Open orders. */ orders: WrapperOpenOrder[]; /** Last update slot number. */ lastUpdatedSlot: number; } /** * OpenOrder on a wrapper. Accurate as of the latest sync. */ export interface WrapperOpenOrder { /** Price as float in atoms of quote per atoms of base. */ price: number; /** Client order id used for cancelling orders. Does not need to be unique. */ clientOrderId: bignum; /** Exchange defined id for an order. */ orderSequenceNumber: bignum; /** Number of base atoms in the order. */ numBaseAtoms: bignum; /** Hint for the location of the order in the manifest dynamic data. */ marketDataIndex: number; /** Last slot before this order is invalid and will be removed. */ lastValidSlot: number; /** Boolean for whether this order is on the bid side. */ isBid: boolean; /** Type of order (Limit, PostOnly, ...). */ orderType: OrderType; /** unused */ padding: number[]; } /** * Wrapper object used for reading data from a wrapper for manifest markets. */ export declare class Wrapper { /** Public key for the market account. */ address: PublicKey; /** Deserialized data. */ private data; /** * Constructs a Wrapper object. * * @param address The `PublicKey` of the wrapper account * @param data Deserialized wrapper data */ private constructor(); /** * Returns a `Wrapper` for a given address, a data buffer * * @param marketAddress The `PublicKey` of the wrapper account * @param buffer The buffer holding the wrapper account data */ static loadFromBuffer({ address, buffer, }: { address: PublicKey; buffer: Buffer; }): Wrapper; /** * Returns a `Wrapper` for a given address, a data buffer * * @param connection The Solana `Connection` object * @param address The `PublicKey` of the wrapper account */ static loadFromAddress({ connection, address, }: { connection: Connection; address: PublicKey; }): Promise<Wrapper>; /** * Updates the data in a Wrapper. * * @param connection The Solana `Connection` object */ reload(connection: Connection): Promise<void>; /** * Get the parsed market info from the wrapper. * * @param marketPk PublicKey for the market * * @return MarketInfoParsed */ marketInfoForMarket(marketPk: PublicKey): WrapperMarketInfo | null; /** * Get the open orders from the wrapper. * * @param marketPk PublicKey for the market * * @return WrapperOpenOrder[] */ openOrdersForMarket(marketPk: PublicKey): WrapperOpenOrder[] | null; /** * Print all information loaded about the wrapper in a human readable format. */ prettyPrint(): void; /** * Deserializes wrapper data from a given buffer and returns a `Wrapper` object * * This includes both the fixed and dynamic parts of the market. * https://github.com/CKS-Systems/manifest/blob/main/programs/wrapper/src/wrapper_state.rs * * @param data The data buffer to deserialize * * @returns WrapperData */ static deserializeWrapperBuffer(data: Buffer): WrapperData; } //# sourceMappingURL=wrapperObj.d.ts.map