> For the complete documentation index, see [llms.txt](https://docs.non-obvious.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.non-obvious.ai/sdks-guide/blockchain-sdks/tokenomics-sdk/getswapamountvolary.md).

# 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 NO.AI SDK, you must have it installed.

You can install NO.AI SDK using either **`npm`** or **`yarn`**. Use the following commands to install NO.AI 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 NO.AI 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.non-obvious.ai/sdks-guide/blockchain-sdks/tokenomics-sdk/getswapamountvolary.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
