bulk_quote
Installation
pip install karrotcapital.spiderswapUsage
Initialization
First, initialize the 'Spiderswap' class with your API key.
from karrotcapital.spiderswap import Spiderswap
spiderswap = Spiderswap(ApiKey);Method: bulk_quote
Description
The 'bulk_quote' 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
'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'from_mint'token to swap, in lamports.'slippage'(float): The acceptable slippage percentage for the swap, in basis points (bps).'providers'(List[str]): An list of liquidity providers.'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
'List[BulkQuoteResponseMap]': A promise that resolves to an list of 'BulkQuoteResponseMap' objects, each containing a provider and its corresponding quote.
'BulkQuoteResponseMap' Class
'BulkQuoteResponseMap' Classclass BulkQuoteResponseMap(TypedDict):
provider: str
quote: QuoteResponseMapExample
async def get_bulk_quotes():
providers = [
"orca",
"raydium",
"meteora",
"meteora-dlmm"
];
try:
quotes = await spiderswap.quote.bulk_quote(
'from_mint_address',
'to_mint_address',
1, # Amount in tokens
0.5, # Slippage percentage
providers,
9, # from_mint_address
9 # to_mint_address
);
print(f"Bulk Quotes: {quotes}")
except Exception as e:
print(f"An error occurred: {e}")
get_bulk_quotes();Implementation Details
This method iterates through the provided list of liquidity providers, fetching a quote for each using the 'get_quote' method, and then compiles these quotes into an list of 'BulkQuoteResponseMap' objects
Last updated