Options
All
  • Public
  • Public/Protected
  • All
Menu

@project-serum/swap - v0.1.0-alpha.20

Index

Classes

Type aliases

Type aliases

SwapParams

SwapParams: { amount: BN; close?: boolean; fromMarket?: Market; fromMint: PublicKey; fromOpenOrders?: PublicKey; fromWallet?: PublicKey; minExchangeRate: ExchangeRate; options?: ConfirmOptions; quoteWallet?: PublicKey; referral?: PublicKey; toMarket?: Market; toMint: PublicKey; toOpenOrders?: PublicKey; toWallet?: PublicKey }

Parameters to perform a swap.

Type declaration

  • amount: BN

    Amount of fromMint to swap in exchange for toMint.

  • Optional close?: boolean

    True if all new open orders accounts should be automatically closed. Currently disabled.

  • Optional fromMarket?: Market

    Market client for the first leg of the swap. Can be given to prevent the client from making unnecessary network requests. It's recommended to use this in most cases. If not given, then swaps across a USD(x) quoted market.

  • fromMint: PublicKey

    Token mint to swap from.

  • Optional fromOpenOrders?: PublicKey

    Open orders account for the first leg of the swap. Can be given to prevent the client from making unnecessary network requests. It's recommended to use this in most cases.

  • Optional fromWallet?: PublicKey

    Wallet for fromMint. If not provided, uses an associated token address for the configured provider.

  • minExchangeRate: ExchangeRate

    The minimum rate used to calculate the number of tokens one should receive for the swap. This is a safety mechanism to prevent one from performing an unexpecteed trade.

  • Optional options?: ConfirmOptions

    RPC options. If not given the options on the program's provider are used.

  • Optional quoteWallet?: PublicKey

    Wallet of the quote currency to use in a transitive swap. Should be either a USDC or USDT wallet. If not provided uses an associated token address for the configured provider.

  • Optional referral?: PublicKey

    Token account to receive the Serum referral fee. The mint must be in the quote currency of the trade (USDC or USDT).

  • Optional toMarket?: Market

    Market client for the second leg of the swap. Can be given to prevent the client from making unnecessary network requests. It's recommended to use this in most cases. If not given, then swaps across a USD(x) quoted market.

  • toMint: PublicKey

    Token mint to swap to.

  • Optional toOpenOrders?: PublicKey

    Open orders account for the second leg of the swap. Can be given to prevent the client from making unnecessary network requests. It's recommended to use this in most cases.

  • Optional toWallet?: PublicKey

    Wallet for toMint. If not provided, uses the associated token address for the configured provider.

Generated using TypeDoc