# Class: WardenBestRate

### Constructors

#### constructor

▸ **new WardenBestRate**(`provider`, `networkName`, `options?`)

Create new instance of WardenBestRate

**Parameters**

| Name          | Type                                                                                    | Description                                                             |
| ------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `provider`    | `Provider`                                                                              | ethersjs' Provider instance                                             |
| `networkName` | `"bsc"` \| `"arbitrum"` \| `"polygon"` \| `"ethereum"` \| `"avalanche"` \| `"optimism"` | Chain name (supported by WardenSwap), `arbitrum` will be supported soon |
| `options`     | `WardenBestRateOption`                                                                  | Options                                                                 |

### Methods

#### approve

▸ **approve**(`signer`, `src`, `allowedAmount?`, `overrides?`): `Promise`<`ContractTransaction`>

Set Allowance of a token to be spendable by WardenSwap contract

**Parameters**

| Name            | Type               | Default value                 | Description                                           |
| --------------- | ------------------ | ----------------------------- | ----------------------------------------------------- |
| `signer`        | `Signer`           | `undefined`                   | ethers' Signer                                        |
| `src`           | `string`           | `undefined`                   | Token to be approved                                  |
| `allowedAmount` | `BigNumberish`     | `ethers.constants.MaxUint256` | Allowed amount to be spendable by WardenSwap contract |
| `overrides`     | `PayableOverrides` | `{}`                          | ethers' overrides                                     |

**Returns**

`Promise`<`ContractTransaction`>

ethers' contract transaction (no wait)

***

#### getDepositAddresses

▸ **getDepositAddresses**(`srcDestRouteTuples`, `dexManager?`): `string`\[]

Get deposit addresses indicating the first hop to be used for starting the trade. This information is required by Wardenswap contract

**Parameters**

| Name                 | Type                                                                 | Description                           |
| -------------------- | -------------------------------------------------------------------- | ------------------------------------- |
| `srcDestRouteTuples` | { `dest`: `string` ; `routeAddress`: `string` ; `src`: `string` }\[] | tuples of src, dest, and routeAddress |
| `dexManager?`        | `DexManager`                                                         | -                                     |

**Returns**

`string`\[]

a list of deposit addresses with the same order as the input

***

#### getQuote

▸ **getQuote**(`src`, `dest`, `amountIn`, `gasPrice`, `opts?`): `Promise`<`QuoteResult`>

Get the best rate of a token pair with given amount

**Parameters**

| Name       | Type             | Description                                                                                                                                                    |
| ---------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `src`      | `string`         | Address of src asset                                                                                                                                           |
| `dest`     | `string`         | Address of dest asset                                                                                                                                          |
| `amountIn` | `BigNumberish`   | Amount of src asset to be traded                                                                                                                               |
| `gasPrice` | `BigNumberish`   | Amount of gas price per unit in native currency (18 decimals) e.g. BSC = BNB, Polygon = MATIC, Ethereum = ETH. For L2 chains, this is Ethereum (L1) gas price. |
| `opts`     | `GetQuoteOption` | Options for getting quote                                                                                                                                      |

**Returns**

`Promise`<`QuoteResult`>

Trading routes which provide the best rate

***

#### swap

▸ **swap**(`signer`, `src`, `dest`, `amountIn`, `minDestAmount`, `quoteResult`, `partnerId?`, `metaData?`, `receiver?`, `overrides?`): `Promise`<`ContractTransaction`>

Send a swap transaction to WardenSwap based on given quote

**Parameters**

| Name            | Type               | Default value | Description                                               |
| --------------- | ------------------ | ------------- | --------------------------------------------------------- |
| `signer`        | `Signer`           | `undefined`   | ethers' Signer                                            |
| `src`           | `string`           | `undefined`   | Source token                                              |
| `dest`          | `string`           | `undefined`   | Destination token                                         |
| `amountIn`      | `BigNumberish`     | `undefined`   | Amount of source token                                    |
| `minDestAmount` | `BigNumberish`     | `undefined`   | Minimum amount of destination token                       |
| `quoteResult`   | `QuoteResult`      | `undefined`   | Best rate quote got from `getQuote` method                |
| `partnerId`     | `BigNumberish`     | `0`           | Warden's partner ID                                       |
| `metaData`      | `BigNumberish`     | `0`           | MetaWarden ID                                             |
| `receiver?`     | `string`           | `undefined`   | Wallet to receive destination token, default to tx sender |
| `overrides`     | `PayableOverrides` | `{}`          | ethers' transaction overrides                             |

**Returns**

`Promise`<`ContractTransaction`>

ethers' contract transaction (no wait)


---

# 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.wardenswap.finance/warden/wardenswap-sdk/references/class-wardenbestrate.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.
