⛏️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.

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

Parameters

NameTypeDescription

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

PropertyTypeDescription

outputAmount

string

The expected output amount of tokens after the swap.

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:

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 Nest 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.

Last updated