get_quote
Installation
Usage
Initialization
First, initialize the 'Spiderswap'
class with your API key.
Method: get_quote
Description
The 'get_quote'
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
'from_mint'
(str): The mint address of the token being swapped from.'to_mint'
(str): The mint address of the token being swapped to.'amount'
(float): The amount of the'fromMint'
token to swap, in lamports.'slippage'
(float): The acceptable slippage percentage for the swap, in basis points (bps).'provider'
(str): The liquidity provider.'from_mint_decimals'
(int, optional): The decimal places for the'from_mint'
token (default is 9).'to_mint_decimals'
(int, optional): The decimal places for the'to_mint'
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 'get_quote_raw'
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