bulkQuote

Installation

npm install @karrotcapital/spiderswap

Usage

Initialization

First, initialize the 'Spiderswap' class with your API key.

import Spiderswap from '@karrotcapital/spiderswap';
// OR
const Spiderswap = require('@karrotcapital/spiderswap');

const spiderswap = new Spiderswap(ApiKey);

Method: bulkQuote

Description

The 'bulkQuote' method retrieves multiple quotes for a token swap from different liquidity providers. This function is useful for comparing quotes from various providers to find the best rates for a token swap on the Solana blockchain.

IMPORTANT: For every provider you use it will make a api call.

Parameters

  • 'fromMint' (string): The mint address of the token being swapped from.

  • 'toMint' (string): The mint address of the token being swapped to.

  • 'amount' (number): The amount of the 'fromMint' token to swap, in lamports.

  • 'slippage' (number): The acceptable slippage percentage for the swap, in basis points (bps).

  • 'providers' (Array): An array of liquidity providers.

  • 'fromMintDecimals'(number, optional): The decimal places for the 'fromMint' token (default is 9).

  • 'toMintDecimals'(number, optional): The decimal places for the 'toMint' token (default is 9).

Returns

'Promise<Array<bulkQuoteResponseMap>>': A promise that resolves to an array of 'bulkQuoteResponseMap' objects, each containing a provider and its corresponding quote.

'bulkQuoteResponseMap' Type

Example

Implementation Details

This method iterates through the provided list of liquidity providers, fetching a quote for each using the 'getQuote' method, and then compiles these quotes into an array of 'bulkQuoteResponseMap' objects

Last updated