⛏️executeSwap
Description
The executeSwap
function enables token swaps between two chains using a third-party API.
It takes in the user's private key, source/destination chain, tokens, amount, receives address and slippage as input and returns the transaction receipt for the swap.
Parameters
Name | Type | Description |
---|---|---|
| string | The private key of the user's wallet for the source chain |
| string | The name of the source blockchain network (e.g., ETH, AVA, BSC, Polygon, Klaytn), and all specified networks are on the mainnet. |
| string | The name of the destination blockchain network (e.g., ETH, AVA, BSC, Polygon, Klaytn), and all specified networks are on the mainnet. |
| string | The address of the token to be swapped on the source blockchain |
| string | The address of the token to receive on the destination blockchain |
| string | The amount of the token to be swapped (in the smallest unit) |
| string | The address to receive the swapped tokens on the destination chain |
| string | The acceptable slippage rate (in percentage) |
Response
Property | Type | Description |
---|---|---|
| object | The receipt of the transaction after the token swap is done |
Example Request and Response
Prerequisites
Before making requests with Nest SDK, you must have it installed.
You can install Nest SDK using either npm
or yarn
. Use the following commands to install Nest SDK:
Request
Here is an example of how to make a executeSwap
request using the Nest SDK:
Response
Use Cases
Cross-chain token swaps: The
executeSwap
function can be used by decentralized exchanges to facilitate cross-chain token swaps, allowing users to trade their tokens across different blockchain networks.Liquidity providers: The function can also be used by liquidity providers to move their funds across different chains and earn higher yields.
Last updated