spur-client - v0.5.1
    Preparing search index...

    Class SpurClient

    Client to access the Spur API.

    Start with fetching a quote using SpurClient.quote and execute a swap using SpurClient.swapInteractive in the browser using a Solana Wallet Adapter or SpurClient.swapNonInteractive in a server or cli application using a Keypair.

    Index

    Constructors

    • Initializes a new client.

      Parameters

      • payer: string = ...

        (optional) base58 encoded PublicKey of wallet signing the swap transaction. If omitted the client will be able to fetch quotes but not to execute swaps.

      Returns SpurClient

    Methods

    • Prepares a quote for on-chain execution.

      Parameters

      • connection: Connection

        to fetch ALT accounts & latestBlockhash

      • quote: SpurQuote

        generated by SpurClient.quote

      • slippage: number

        configure transaction failure in case the executed price differs from the quoted price by more than the configured fraction. Example value for 1%: 0.01.

      • OptionalpriorityLamports: bigint

        (optional) Fee paid to validators for block inclusion preference in lamports. If omitted a recent value is queried using SpurClient.getPriorityLamports("medium").

      • Optionalblockhash: Readonly<{ blockhash: string; lastValidBlockHeight: number }>

        (optional) Recent blockhash to limit transaction validity. If ommitted a recent value is queried using connection.getLatestBlockhash("finalized").

      Returns Promise<SpurCompiledSwap>

    • Fetch AddressLookupTableAccounts of a given quote either from a local cache or the provided Connection.

      Parameters

      Returns Promise<AddressLookupTableAccount[]>

    • Parameters

      Returns TransactionInstruction[]

    • Executor instructions execute swap.

      Parameters

      Returns TransactionInstruction[]

    • Fetch a recommended priority tip either from a local cache or the Spur API.

      Parameters

      Returns Promise<bigint>

    • Fetch a fresh quote from the Spur API. The returned quote can be passed to SpurClient.swapInteractive to trigger interactive wallet signing with a Solana Wallet adapter compatible wallet and submit the transaction on-chain. Use SpurClient.swapNonInteractive for signing using a Keypair inside a server or cli application. To customize the transaction submission process, use SpurClient.compileSwap to generate a SpurCompiledSwap and familiarize yourself with the source code of the beforementioned methods.

      Parameters

      • inputAmount: bigint

        u64 native atoms

      • inputMint: string

        base58 encoded PublicKey

      • outputMint: string

        base58 encoded PublicKey

      • Optionallimits: Limits

        (optional) customize the resource constraints of the swap transaction

      Returns Promise<SpurQuote>

    • Execute a swap for the given Quote using a Solana Wallet Adapter for generating signatures.

      Parameters

      • connection: Connection

        to fetch ALT accounts & latestBlockhash

      • quote: SpurQuote

        generated by SpurClient.quote

      • wallet: SignerWalletAdapter
      • slippage: number

        configure transaction failure in case the executed price differs from the quoted price by more than the configured fraction. Example value for 1%: 0.01.

      • OptionalpriorityLamports: bigint

        (optional) Fee paid to validators for block inclusion preference in lamports. If omitted a recent value is queried using SpurClient.getPriorityLamports("medium").

      Returns Promise<string>

      signature of the swap transaction after it has been confirmed

    • Execute a swap for the given Quote using a Keypair for generating signatures.

      Parameters

      • connection: Connection

        to fetch ALT accounts & latestBlockhash

      • quote: SpurQuote

        generated by SpurClient.quote

      • signer: Signer

        a solana/web3.js Keypair

      • slippage: number

        configure transaction failure in case the executed price differs from the quoted price by more than the configured fraction. Example value for 1%: 0.01.

      • OptionalpriorityLamports: bigint

        (optional) Fee paid to validators for block inclusion preference in lamports. If omitted a recent value is queried using SpurClient.getPriorityLamports("medium").

      Returns Promise<TransactionError>

      signature of the swap transaction after it has been confirmed