# Aggregation VulpeFI

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

* [ClipperRouter](https://docs.vulpefi.com/aggregation-protocol/smart-contracts/clipperrouter)
* [LimitOrderProtocol](https://docs.vulpefi.com/aggregation-protocol/smart-contracts/limitorderprotocol)
* [UnoswapRouter](https://docs.vulpefi.com/aggregation-protocol/smart-contracts/unoswaprouter)
* [Permitable](https://docs.vulpefi.com/aggregation-protocol/smart-contracts/broken-reference)
* [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/drafts#EIP712)
* [EthReceiver](https://docs.vulpefi.com/aggregation-protocol/smart-contracts/broken-reference)
* [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         |             |
