> For the complete documentation index, see [llms.txt](https://docs.wardenswap.finance/warden/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wardenswap.finance/warden/wardenswap-sdk/references/class-wardenpayloadcompressor.md).

# Class: WardenPayloadCompressor

### Constructors

#### constructor

• **new WardenPayloadCompressor**(`networkName`, `provider`, `multicallOptions?`)

Create new instance of WardenPayloadCompressor

**Parameters**

| Name                | Type                                                                                    | Description                          |
| ------------------- | --------------------------------------------------------------------------------------- | ------------------------------------ |
| `networkName`       | `"bsc"` \| `"arbitrum"` \| `"polygon"` \| `"ethereum"` \| `"avalanche"` \| `"optimism"` | Chain name (supported by WardenSwap) |
| `provider`          | `Provider`                                                                              | ethersjs' Provider                   |
| `multicallOptions?` | `MulticallBatchOption`                                                                  | Multicall options                    |

### Methods

#### compress

▸ **compress**(`src`, `dest`, `amountIn`, `minDestAmount`, `partnerId`, `metaData`, `swapAddress`, `receiver`, `paths`, `volumes`): `Promise`<`string`>

Compress calldata for L2 chains

**Parameters**

| Name            | Type                            | Description                                             |
| --------------- | ------------------------------- | ------------------------------------------------------- |
| `src`           | `string`                        | Source Token                                            |
| `dest`          | `string`                        | Destination Token                                       |
| `amountIn`      | `BigNumberish`                  | Amount of source token                                  |
| `minDestAmount` | `BigNumberish`                  | Minimum amount of destination token required            |
| `partnerId`     | `BigNumberish`                  | Warden's partner ID                                     |
| `metaData`      | `BigNumberish`                  | MetaWarden data                                         |
| `swapAddress`   | `string`                        | Warden swap contract                                    |
| `receiver`      | `string`                        | Receiver wallet                                         |
| `paths`         | `PathResult` \| `PathResult`\[] | Path result(s) gathered from `getQuote`                 |
| `volumes`       | `number`\[]                     | Splitting ratio of source token amount range from 1-100 |

**Returns**

`Promise`<`string`>

Serialized data to be used with swap functions with compression feature

***

#### encodeSwapData

▸ **encodeSwapData**(`paths`): `string`

Encode swap data for L1 chains

**Parameters**

| Name    | Type                            | Description                             |
| ------- | ------------------------------- | --------------------------------------- |
| `paths` | `PathResult` \| `PathResult`\[] | Path result(s) gathered from `getQuote` |

**Returns**

`string`

A hexadecimal string representing encoded swap data

***

#### encodeSwapDataL2

▸ **encodeSwapDataL2**(`paths`, `volumes`, `addressIdxMap?`): `Promise`<`string`>

Compress swap data for L2 chains

**Parameters**

| Name             | Type                            | Description                                              |
| ---------------- | ------------------------------- | -------------------------------------------------------- |
| `paths`          | `PathResult` \| `PathResult`\[] | Path result(s) gathered from `getQuote`                  |
| `volumes`        | `number`\[]                     | Splitting ratio of source token amount range from 1-100  |
| `addressIdxMap?` | `Object`                        | Address-index map gathered from ArbAddressTable contract |

**Returns**

`Promise`<`string`>

A hexadecimal string representing compressed swap data


---

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