getQuote
Installation
Usage
Initialization
First, initialize the 'Spiderswap'
class with your API key.
Method: getQuote
Description
The 'getQuote'
method retrieves a quote for a token swap, converting the amount to lamports and the slippage to basis points (bps) before making the 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).'provider'
(string): The liquidity provider.'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<quoteResponseMap>'
: A promise that resolves to a 'quoteResponseMap'
object containing the quote data.
'quoteResponseMap'
Type
'quoteResponseMap'
TypeExample
Implementation Details
This method converts the 'amount'
to lamports and the 'slippage'
to basis points (bps) before calling the 'getQuoteRaw'
method to fetch the quote data from the API. It then converts the amounts back to their original units and constructs a 'quoteResponseMap'
object.
Last updated