# getSwapAmountVolary

## Description

The `getSwapAmountVolary` function is used to calculate the expected output amount of a Volary token swap based on the input amount and the selected exchange, with an optional slippage tolerance parameter.&#x20;

The function uses the Uniswap or Sushiswap router contract to get the swap rate and then calculates the expected output amount.

## Parameters

| Name         | Type   | Description                                                                                                   |
| ------------ | ------ | ------------------------------------------------------------------------------------------------------------- |
| `inAmount`   | string | The input amount of Volary tokens to be swapped.                                                              |
| `privateKey` | string | The private key of the user's wallet.                                                                         |
| `exchange`   | string | The exchange to use for the swap calculation. Supported values are "uniswap", "sushiswap", and "pancakeswap". |
| `slippage`   | string | Optional parameter to set the slippage tolerance for the swap calculation, default is 50.                     |

## Response

| Property       | Type   | Description                                          |
| -------------- | ------ | ---------------------------------------------------- |
| `outputAmount` | string | The expected output amount of tokens after the swap. |

## Example Request and Response

### Prerequisites

Before making requests with Volary SDK, you must have it installed.

You can install Volary SDK using either **`npm`** or **`yarn`**. Use the following commands to install Volary SDK:

```jsx
npm install @nest25/tokenomics-lib
OR
yarn add @nest25/tokenomics-lib
```

### Request

Here is an example of how to make a `getSwapAmountVolary` request using the Volary SDK:

```
// import Nest SDK library
const { dex } = require('@nest25/tokenomics-lib');

// create a new instance of the dex class
const Dex = new dex();

async function main() {
  // get swap amount from Volary
  const result = await Dex.getSwapAmountVolary('0.001', TEST_PRIVATE_KEY, 'uniswap');
  // log the result
  console.log(result);
}
main();
```

### Response

```
 Received 262895397847755609 VLRY
```

## Use Cases

* **Automated Trading Bots:** The `getSwapAmountVolary` function can be used by trading bots to calculate the expected output of a Volary token swap and execute the trade based on the predicted output.
* **Portfolio Management:** The function can be used by portfolio managers to determine the expected value of a Volary token swap before making a decision to execute the trade.
* **Crypto Exchanges:** Crypto exchanges can use this function to calculate the expected output amount for a Volary token swap and display it to users before they execute the trade on their platform.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.volary.io/sdks-guide/blockchain-sdks/tokenomics-sdk/getswapamountvolary.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
