Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Market

A Serum DEX Market object

Hierarchy

  • Market

Index

Constructors

constructor

  • new Market(marketState: MarketState, orderbookState: MarketState, address: PublicKey, baseDecimals: number, quoteDecimals: number, options: MarketOptions, programdId: PublicKey, baseVault: PublicKey, quoteVault: PublicKey, eventQueueAddress: PublicKey, orderbookAddress: PublicKey): Market
  • Parameters

    • marketState: MarketState
    • orderbookState: MarketState
    • address: PublicKey
    • baseDecimals: number
    • quoteDecimals: number
    • options: MarketOptions
    • programdId: PublicKey
    • baseVault: PublicKey
    • quoteVault: PublicKey
    • eventQueueAddress: PublicKey
    • orderbookAddress: PublicKey

    Returns Market

Properties

Private _address

_address: PublicKey

Address of the Serum DEX market

Private _baseDecimals

_baseDecimals: number

Number of decimals of the base token

Private _baseSplTokenMultiplier

_baseSplTokenMultiplier: BN

Base token multiplier

Private _baseVault

_baseVault: PublicKey

Base vault address of the market

Private _commitment

_commitment: Commitment

Commitment option (used in the connection object)

Private _eventQueueAddress

_eventQueueAddress: PublicKey

Event queue address of the market

Private _marketState

_marketState: MarketState

Market state

Private _minOrderSize

_minOrderSize: number

Private _orderbookAddress

_orderbookAddress: PublicKey

Address of the orderbook or AAOB market

Private _orderbookState

_orderbookState: MarketState

Asset agnostic orderbook state

Private _programId

_programId: PublicKey

Serum program ID of the market

Private _quoteDecimals

_quoteDecimals: number

Number of decimals of the quote token

Private _quoteSplTokenMultiplier

_quoteSplTokenMultiplier: BN

Quote token multiplier

Private _quoteVault

_quoteVault: PublicKey

Quote vault address of the market

Private _skipPreflight

_skipPreflight: boolean

Preflight option (used in the connection object for sending tx)

Private _tickSize

_tickSize: number

Accessors

address

  • get address(): PublicKey
  • Return the market address

    Returns PublicKey

asksAddress

  • get asksAddress(): PublicKey
  • Returns the asks address (AOB program) of the market

    Returns PublicKey

baseDecimals

  • get baseDecimals(): number
  • Returns the number of decimals of the quote spl-token

    Returns number

baseMintAddress

  • get baseMintAddress(): PublicKey
  • Returns the mint address of the base token

    Returns PublicKey

baseVault

  • get baseVault(): PublicKey
  • Returns the base vault address of the market

    Returns PublicKey

bidsAddress

  • get bidsAddress(): PublicKey
  • Returns the bids address (AOB program) of the market

    Returns PublicKey

eventQueueAddress

  • get eventQueueAddress(): PublicKey
  • Returns the event queue address of the market

    Returns PublicKey

marketState

  • get marketState(): MarketState
  • Returns the market state

    Returns MarketState

minOrderSize

  • get minOrderSize(): number
  • Returns the min order size of the market

    Returns number

orderbookAddress

  • get orderbookAddress(): PublicKey
  • Returns the orderbook address of the market

    Returns PublicKey

orderbookState

  • get orderbookState(): MarketState
  • Returns the orderbook state

    Returns MarketState

programId

  • get programId(): PublicKey
  • Returns the Serum program ID of the market

    Returns PublicKey

quoteDecimals

  • get quoteDecimals(): number
  • Returns the number of decimals of the quote spl-token

    Returns number

quoteMintAddress

  • get quoteMintAddress(): PublicKey
  • Returns the mint address of the quote token

    Returns PublicKey

quoteVault

  • get quoteVault(): PublicKey
  • Returns the quote vault address of the market

    Returns PublicKey

tickSize

  • get tickSize(): number
  • Returns the tick size of the market

    Returns number

Methods

Private _sendTransaction

  • _sendTransaction(connection: Connection, transaction: Transaction, signers: Keypair[]): Promise<string>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    • transaction: Transaction

      The transaction to sign and send

    • signers: Keypair[]

      The signers of the transaction

    Returns Promise<string>

    Returns the signature of the signed and sent transaction

baseSplSizeToNumber

  • baseSplSizeToNumber(size: BN): number
  • Returns the base token multiplier

    Parameters

    • size: BN

    Returns number

baseVolume

  • baseVolume(): number
  • Returns the inception base volume

    Returns number

cancelInBatch

  • cancelInBatch(connection: Connection, orders: OrderInfo[], owner: Keypair): Promise<string>
  • Parameters

    • connection: Connection
    • orders: OrderInfo[]
    • owner: Keypair

    Returns Promise<string>

cancelOrderByOrderId

  • cancelOrderByOrderId(connection: Connection, orderId: BN, owner: Keypair): Promise<string>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    • orderId: BN

      The id of the order to cancel

    • owner: Keypair

      The owner of the order

    Returns Promise<string>

    The signature of the cancel transaction

cancelOrderByOrderIndex

  • cancelOrderByOrderIndex(connection: Connection, orderIndex: number, owner: Keypair): Promise<string>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    • orderIndex: number

      The index of the order in the open order account

    • owner: Keypair

      The owner of the order

    Returns Promise<string>

    The signature of the cancel transaction

filterForOpenOrders

  • filterForOpenOrders(orderbook: Orderbook, openOrder: OpenOrders): { feeTier: number; openOrdersAddress: PublicKey; orderId: BN; price: number; side: Side; size: number }[]
  • Parameters

    • orderbook: Orderbook

      The orderbook of the market

    • openOrder: OpenOrders

      The openOrder that owns the orders

    Returns { feeTier: number; openOrdersAddress: PublicKey; orderId: BN; price: number; side: Side; size: number }[]

filterForOpenOrdersFromSlab

  • filterForOpenOrdersFromSlab(slab: Slab, openOrders: OpenOrders, side: Side): { feeTier: number; openOrdersAddress: PublicKey; orderId: BN; price: number; side: Side; size: number }[]
  • Parameters

    • slab: Slab

      Slab to extract open orders from

    • openOrders: OpenOrders

      Open orders account

    • side: Side

    Returns { feeTier: number; openOrdersAddress: PublicKey; orderId: BN; price: number; side: Side; size: number }[]

findBaseTokenAccountsForOwner

  • findBaseTokenAccountsForOwner(owner: PublicKey): Promise<PublicKey>
  • Fetch the associated token account of the owner for the base token of the market

    Parameters

    • owner: PublicKey

      The public key of the owner

    Returns Promise<PublicKey>

    The public key of the associated token account of the owner

findFeeDiscountKeys

  • findFeeDiscountKeys(connection: Connection, owner: PublicKey): Promise<{ balance: any; feeTier: number; mint: PublicKey; pubkey: PublicKey }[]>
  • This method returns the fee discount keys assuming (M)SRM tokens are held in associated token account.

    Parameters

    • connection: Connection

      The solana connection object to the RPC node

    • owner: PublicKey

      The public key of the (M)SRM owner

    Returns Promise<{ balance: any; feeTier: number; mint: PublicKey; pubkey: PublicKey }[]>

    An array of { pubkey: PublicKey, mint: PublicKey, balance: number, feeTier: number }

findOpenOrdersAccountForOwner

  • findOpenOrdersAccountForOwner(connection: Connection, owner: PublicKey): Promise<OpenOrders>
  • Fetch the open order account of the owner

    Parameters

    • connection: Connection
    • owner: PublicKey

      The public key of the owner

    Returns Promise<OpenOrders>

    The public key of the open order account

findQuoteTokenAccountsForOwner

  • findQuoteTokenAccountsForOwner(owner: PublicKey): Promise<PublicKey>
  • Fetch the associated token account of the owner for the quote token of the market

    Parameters

    • owner: PublicKey

      The public key of the owner

    Returns Promise<PublicKey>

    The public key of the associated token account of the owner

loadAsks

  • loadAsks(connection: Connection): Promise<Slab>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    Returns Promise<Slab>

    The decoded asks of the market

loadBids

  • loadBids(connection: Connection): Promise<Slab>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    Returns Promise<Slab>

    The decoded bids of the market

loadEventQueue

  • loadEventQueue(connection: Connection): Promise<EventQueue>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    Returns Promise<EventQueue>

    The deserialized event queue of the market

loadFills

  • loadFills(connection: Connection, limit?: number): Promise<(EventFill | EventOut)[]>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    • limit: number = 100

      Optional limit parameters to the number of fills fetched

    Returns Promise<(EventFill | EventOut)[]>

loadOrdersForOwner

  • loadOrdersForOwner(connection: Connection, owner: PublicKey): Promise<{ feeTier: number; openOrdersAddress: PublicKey; orderId: BN; price: number; side: Side; size: number }[]>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    • owner: PublicKey

      The owner of the orders to fetch

    Returns Promise<{ feeTier: number; openOrdersAddress: PublicKey; orderId: BN; price: number; side: Side; size: number }[]>

makeCancelOrderInstruction

  • makeCancelOrderInstruction(orderIndex: BN, orderId: BN, owner: PublicKey): Promise<Transaction>
  • Parameters

    • orderIndex: BN

      The index of the order in the open order account

    • orderId: BN
    • owner: PublicKey

      The owner of the order

    Returns Promise<Transaction>

makePlaceOrderTransaction

  • makePlaceOrderTransaction(side: Side, limitPrice: number, size: number, orderType: OrderType, selfTradeBehavior: SelfTradeBehavior, ownerTokenAccount: PublicKey, owner: PublicKey, discountTokenAccount?: PublicKey): Promise<TransactionInstruction>
  • Returns a TransactionInstruction to place an order

    Parameters

    • side: Side

      The side of the order (cf Side enum)

    • limitPrice: number

      The limit price of the order

    • size: number

      The size of the order

    • orderType: OrderType

      The type of the order (cf OrderType enum)

    • selfTradeBehavior: SelfTradeBehavior

      The behavior of the order in case of self trade (cf SelfTradeBehavior enum)

    • ownerTokenAccount: PublicKey

      The token account of the owner of the wallet placing the trade (owner)

    • owner: PublicKey

      The owner of the order

    • Optional discountTokenAccount: PublicKey

      Optional (M)SRM token account for fee discount

    Returns Promise<TransactionInstruction>

    Returns a TransactionInstruction object

makeSettleFundsTransaction

  • makeSettleFundsTransaction(owner: PublicKey, destinationBaseAccount: PublicKey, destinationQuoteAccount: PublicKey): Promise<Transaction>
  • Parameters

    • owner: PublicKey

      Owner of the funds to settle

    • destinationBaseAccount: PublicKey

      The owner base token account

    • destinationQuoteAccount: PublicKey

      The owner quote token account

    Returns Promise<Transaction>

marketCreation

  • marketCreation(): number
  • Returns the timestamp of the market creation

    Returns number

placeOrder

  • placeOrder(connection: Connection, side: Side, limitPrice: number, size: number, orderType: OrderType, selfTradeBehavior: SelfTradeBehavior, ownerTokenAccount: PublicKey, owner: Keypair, discountTokenAccount?: PublicKey): Promise<string>
  • Sign and send a place order transaction

    Parameters

    • connection: Connection

      The solana connection object to the RPC node

    • side: Side

      The side of the order (cf Side enum)

    • limitPrice: number

      The limit price of the order

    • size: number

      The size of the order

    • orderType: OrderType

      The type of the order (cf OrderType enum)

    • selfTradeBehavior: SelfTradeBehavior

      The behavior of the order in case of self trade (cf SelfTradeBehavior enum)

    • ownerTokenAccount: PublicKey

      The token account of the owner of the wallet placing the trade (owner)

    • owner: Keypair

      The owner of the order

    • Optional discountTokenAccount: PublicKey

      Optional (M)SRM token account for fee discount

    Returns Promise<string>

    The signature of the transaction

quoteSplSizeToNumber

  • quoteSplSizeToNumber(size: BN): number
  • Returns the quote token multiplier

    Parameters

    • size: BN

    Returns number

quoteVolume

  • quoteVolume(): number
  • Returns the inception quote volume

    Returns number

settleFunds

  • settleFunds(connection: Connection, owner: Keypair, destinationBaseAccount: PublicKey, destinationQuoteAccount: PublicKey): Promise<string>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    • owner: Keypair

      The owner of the funds to settle

    • destinationBaseAccount: PublicKey

      The owner base token account

    • destinationQuoteAccount: PublicKey

      The owner quote token account

    Returns Promise<string>

    The signature of the settle transaction

Static load

  • load(connection: Connection, address: PublicKey, programId?: PublicKey, options?: MarketOptions): Promise<Market>
  • Parameters

    • connection: Connection

      The solana connection object to the RPC node

    • address: PublicKey

      Address of the Serum market to load

    • programId: PublicKey = ...

      Program ID of Serum

    • options: MarketOptions = {}

      MarketOptions object (skipPreflight and Commitment)

    Returns Promise<Market>

    Returns a market object

Generated using TypeDoc