# getQuote

## Description

The `getQuote` function returns an object containing the contract address and quotes for a given token swap between two chains, based on the source and destination chain, source and destination tokens, and the amount to be swapped.&#x20;

If the request is unsuccessful, it returns an error message.

## Parameters

<table><thead><tr><th>Parameter</th><th width="105">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>srcChain</code></td><td>string</td><td>The name of the source blockchain network (e.g., ETH, AVA, BSC, Polygon, Klaytn), and all specified networks are on the mainnet.</td></tr><tr><td><code>destChain</code></td><td>string</td><td>The name of the destination blockchain network (e.g., ETH, AVA, BSC, Polygon, Klaytn), and all specified networks are on the mainnet.</td></tr><tr><td><code>fromToken</code></td><td>string</td><td>The contract address of the token being swapped on the source chain</td></tr><tr><td><code>toToken</code></td><td>string</td><td>The contract address of the token being swapped on the destination chain</td></tr><tr><td><code>amount</code></td><td>string</td><td>The amount of tokens being swapped</td></tr></tbody></table>

## Response

<table><thead><tr><th>Property</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>contractAddress</code></td><td>string</td><td>The contract address of the token on the destination chain</td></tr><tr><td><code>quote</code></td><td>string</td><td>The estimated amount of tokens to receive on the destination chain after the swap</td></tr><tr><td><code>code</code></td><td>string</td><td>Error code if the quote is unsuccessful </td></tr><tr><td><code>msg</code></td><td>string</td><td>Error message if the quote is unsuccessful</td></tr></tbody></table>

## 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/xy-finance-lib
OR
yarn add @nest25/xy-finance-lib
```

### Request

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

````javascript
// import Nest SDK library
const { xySwap } = require('@nest25/xy-finance-lib');

// create xySwap instance
const swap = new xySwap();

async function main() {
  // get quote
  const response = await swap.getQuote(
    'klaytn',
    'klaytn',
    '0xCF87f94fD8F6B6f0b479771F10dF672f99eADa63',
    '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
    '10',
  );
  console.log(response);
}
// run main function
main();

```
````

### Response

```sh
{
      contractAddress: '0x52075Fd1fF67f03beABCb5AcdA9679b02d98cA37',
      quote: {
        sourceChainSwaps: { dexNames: [Array], fromToken: [Object], toToken: [Object] },
        crossChainSwap: null,
        destChainSwaps: null,
        toTokenAmount: '0.8281407505663061'
      }
    }
```

## Use Cases

* **Token swapping:** The `getQuote` function can be used by decentralized exchanges to get a quote for a cross-chain token swap before initiating a trade, ensuring the accuracy of the transaction.
* **Portfolio management:** The function can be used to help portfolio managers determine the expected outcome of a token swap before making the trade.
* **Arbitrage opportunities:** The function can be used to identify potential arbitrage opportunities by comparing the estimated swap amount with the current market price of the tokens on both chains.
