Options
All
  • Public
  • Public/Protected
  • All
Menu

A wrapper class around serum-ts's Market class.

Hierarchy

  • DexMarket

Index

Constructors

  • new DexMarket(address: PublicKey, serumMarket: Market, baseCoin: Coin, quoteCoin: Coin): DexMarket

Properties

_address: PublicKey
_baseCoin: Coin
_marketSymbol: string
_quoteCoin: Coin
_serumMarket: Market

Accessors

  • get address(): PublicKey
  • get baseCoin(): Coin
  • get marketSymbol(): string
  • get quoteCoin(): Coin
  • get serumMarket(): Market

Methods

  • cancelOrder(connection: Connection, owner: Keypair, serumMarket: Market, order: Order): Promise<string>
  • Cancel an order on the DexMarket.

    Parameters

    • connection: Connection

      The Connection object to connect to Solana.

    • owner: Keypair

      The PublicKey of the owner of the order.

    • serumMarket: Market

      The Market object from serum-ts package.

    • order: Order

      The Order object to cancel.

    Returns Promise<string>

  • createMarketAccountsInstructions(accounts: MarketAccounts, payer: Keypair, connection: Connection, programID: PublicKey): Promise<TransactionInstruction[]>
  • Create a Transaction object for creating the accounts required for a DexMarket.

    Parameters

    • accounts: MarketAccounts

      The MarketAccounts object containing the accounts needed for initializing the market.

    • payer: Keypair

      The Keypair object of the account that will pay for the transaction.

    • connection: Connection

      The Connection object to connect to Solana.

    • programID: PublicKey

      The address of the serum-dex program deployed.

    Returns Promise<TransactionInstruction[]>

  • createMarketVaultsTransaction(payer: Keypair, vaultOwner: PublicKey, baseVault: Keypair, quoteVault: Keypair, baseCoin: Coin, quoteCoin: Coin, connection: Connection): Promise<Transaction>
  • Create a Transaction object for creating the vaults required for a DexMarket.

    Parameters

    • payer: Keypair

      The Keypair of the account that will pay for the transaction.

    • vaultOwner: PublicKey

      The address assigned as the owner of the vault.

    • baseVault: Keypair

      The Token Account that would be used as the base vault.

    • quoteVault: Keypair

      The Token Account that would be used as the quote vault.

    • baseCoin: Coin

      The base Coin object provided by the Coin class.

    • quoteCoin: Coin

      The quote Coin object provided by the Coin class.

    • connection: Connection

      The Connection object to connect to Solana.

    Returns Promise<Transaction>

  • getCancelOrderTransaction(connection: Connection, owner: Keypair, serumMarket: Market, order: Order): Promise<TransactionWithSigners>
  • Create a Transaction object for cancelling an order.

    Parameters

    • connection: Connection

      The Connection object to connect to Solana.

    • owner: Keypair

      The Keypair of the owner of the order.

    • serumMarket: Market

      The Market object from serum-ts package.

    • order: Order

      The Order object to cancel.

    Returns Promise<TransactionWithSigners>

  • getOrCreateOpenOrderAccount(owner: Keypair, serumMarket: Market, connection: Connection): Promise<OpenOrders>
  • Get or create an OpenOrder account for the specified owner.

    Parameters

    • owner: Keypair

      The Keypair for which OpenOrders account is required.

    • serumMarket: Market

      The Market object from serum-ts package.

    • connection: Connection

      The Connection object to connect to Solana.

    Returns Promise<OpenOrders>

  • getOrdersForOwner(owner: Keypair, serumMarket: Market, connection: Connection): Promise<Order[]>
  • Get all orders placed by a keypair.

    Parameters

    • owner: Keypair

      The Keypair for which orders have to be fetched.

    • serumMarket: Market

      The Market object from serum-ts package.

    • connection: Connection

      The Connection object to connect to Solana.

    Returns Promise<Order[]>

  • Create a Transaction object for placing an order.

    Parameters

    • connection: Connection

      The Connection object to connect to Solana.

    • owner: Keypair

      The Keypair of the owner of the order.

    • serumMarket: Market

      The Market object from serum-ts package.

    • side: "buy" | "sell"

      The Side of the order.

    • orderType: OrderType

      The OrderType of the order.

    • size: number

      The size of the order.

    • price: number

      The price of the order.

    • Optional selfTradeBehaviour: SelfTradeBehaviour

      The SelfTradeBehaviour action to follow for the order placed.

    Returns Promise<TransactionWithSigners>

  • load(connection: Connection, programID: PublicKey, marketAddress: PublicKey, baseCoin: Coin, quoteCoin: Coin): Promise<DexMarket>
  • Load a DexMarket instance from a given market address.

    Parameters

    • connection: Connection

      The Connection object to connect to Solana.

    • programID: PublicKey

      The address of the serum-dex program deployed.

    • marketAddress: PublicKey

      The address of the market to load.

    • baseCoin: Coin

      The base Coin object provided by the Coin class.

    • quoteCoin: Coin

      The quote Coin object provided by the Coin class.

    Returns Promise<DexMarket>

  • placeOrder(connection: Connection, owner: Keypair, serumMarket: Market, side: "buy" | "sell", orderType: OrderType, size: number, price: number, selfTradeBehaviour?: SelfTradeBehaviour): Promise<string>
  • Place an order on the DexMarket.

    Parameters

    • connection: Connection

      The Connection object to connect to Solana.

    • owner: Keypair

      The Keypair of the owner of the order.

    • serumMarket: Market

      The Market object from serum-ts package.

    • side: "buy" | "sell"

      The Side of the order.

    • orderType: OrderType

      The OrderType of the order.

    • size: number

      The size of the order.

    • price: number

      The price of the order.

    • Optional selfTradeBehaviour: SelfTradeBehaviour

      The SelfTradeBehaviour action to follow for the order placed.

    Returns Promise<string>

  • sanityCheck(serumMarket: Market, price: number, size: number): void
  • Parameters

    • serumMarket: Market
    • price: number
    • size: number

    Returns void

Generated using TypeDoc