getSwapRaw
Installation
Usage
Initialization
First, initialize the 'Spiderswap'
class with your API key.
Method: getSwapRaw
Description
The 'getSwapRaw
' method facilitates token swaps by fetching raw swap data from the SpiderSwap API.
Parameters
'owner'
(string): The wallet address of the owner initiating the swap.'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 bps.'provider'
(string): The liquidity provider.'pool'
(string | null, optional): The specific pool for the swap (default isnull
).
Returns
'Promise<swapResponse>'
: A promise that resolves to a base64-encoded string containing the raw swap data.
'swapResponse'
Type
'swapResponse'
TypeExample
Error Handling
The method throws an error if the swap data cannot be fetched, logging the error details for debugging.
Last updated