> For the complete documentation index, see [llms.txt](https://docs.vulpefi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vulpefi.com/aggregation-protocol/smart-contracts/aggregation-vulpefi.md).

# Aggregation VulpeFI

## Derives[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#derives) <a href="#derives" id="derives"></a>

* [ClipperRouter](/aggregation-protocol/smart-contracts/clipperrouter.md)
* [LimitOrderProtocol](/aggregation-protocol/smart-contracts/limitorderprotocol.md)
* [UnoswapRouter](/aggregation-protocol/smart-contracts/unoswaprouter.md)
* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/drafts#EIP712)
* [EthReceiver](broken://pages/iW8VH14sl4YfZUdHor2O)
* [Ownable](https://docs.openzeppelin.com/contracts/3.x/api/access#Ownable)
* [Context](https://docs.openzeppelin.com/contracts/3.x/api/utils#Context)

## Functions[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#functions) <a href="#functions" id="functions"></a>

### constructor[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#constructor) <a href="#constructor" id="constructor"></a>

```javascript
function constructor(
  address weth,
  contract IClipperExchangeInterface _clipperExchange
) public
```

**Parameters:**

<table><thead><tr><th width="211">Name</th><th width="229">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>weth</code></td><td>address</td><td></td></tr><tr><td><code>_clipperExchange</code></td><td>contract IClipperExchangeInterface</td><td></td></tr></tbody></table>

### swap[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#swap) <a href="#swap" id="swap"></a>

```javascript
function swap(
  contract IAggregationExecutor caller,
  struct AggregationRouterV4.SwapDescription desc,
  bytes data
) external returns (uint256 returnAmount, uint256 gasLeft)
```

Performs a swap, delegating all calls encoded in `data` to `caller`. See tests for usage examples

**Parameters:**

<table><thead><tr><th width="133">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>caller</code></td><td>contract IAggregationExecutor</td><td>Aggregation executor that executes calls described in <code>data</code></td></tr><tr><td><code>desc</code></td><td>struct AggregationRouterV4.SwapDescription</td><td>Swap description</td></tr><tr><td><code>data</code></td><td>bytes</td><td>Encoded calls that <code>caller</code> should execute in between of swaps</td></tr></tbody></table>

**Return Values:**

<table><thead><tr><th width="184">Name</th><th width="93">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>returnAmount</code></td><td>uint256</td><td>Resulting token amount</td></tr><tr><td><code>gasLeft</code></td><td>uint256</td><td>Gas left</td></tr></tbody></table>

### rescueFunds[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#rescuefunds) <a href="#rescuefunds" id="rescuefunds"></a>

```javascript
function rescueFunds(
  contract IERC20 token,
  uint256 amount
) external
```

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#parameters-2)

| Name     | Type            | Description |
| -------- | --------------- | ----------- |
| `token`  | contract IERC20 |             |
| `amount` | uint256         |             |

### destroy <a href="#destroy" id="destroy"></a>

```
unction destroy(
) external
```

## Events[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#events) <a href="#events" id="events"></a>

### Swapped[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#swapped) <a href="#swapped" id="swapped"></a>

```javascript
event Swapped(
  address sender,
  contract IERC20 srcToken,
  contract IERC20 dstToken,
  address dstReceiver,
  uint256 spentAmount,
  uint256 returnAmount
)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#parameters-3)

| Name           | Type            | Description |
| -------------- | --------------- | ----------- |
| `sender`       | address         |             |
| `srcToken`     | contract IERC20 |             |
| `dstToken`     | contract IERC20 |             |
| `dstReceiver`  | address         |             |
| `spentAmount`  | uint256         |             |
| `returnAmount` | uint256         |             |


---

# 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.vulpefi.com/aggregation-protocol/smart-contracts/aggregation-vulpefi.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.
