# DexAggregatorUManager

[Git Source](https://github.com/Ion-Protocol/nucleus-boring-vault/blob/cc0b494b83e17b9b169a73b96050d2810b690477/src/micro-managers/DexAggregatorUManager.sol)

**Inherits:** UManager

Required Merkle Root Leaves

* ERC20 approves with `router` spender.
* AggregationRouterV5.swap, with all desired addresses.

## State Variables

### MAX\_SLIPPAGE

```solidity
uint256 internal constant MAX_SLIPPAGE = 0.1e4;
```

### allowedSlippage

Slippage check enforced after swaps.

```solidity
uint16 public allowedSlippage = 0.0005e4;
```

### router

The 1Inch Router.

```solidity
AggregationRouterV5 internal immutable router;
```

### priceRouter

The PriceRouter contract used to check slippage.

```solidity
PriceRouter internal immutable priceRouter;
```

## Functions

### constructor

```solidity
constructor(
    address _owner,
    address _manager,
    address _boringVault,
    address _router,
    address _priceRouter
)
    UManager(_owner, _manager, _boringVault);
```

### setAllowedSlippage

Sets the maximum allowed slippage during a swap.

*Callable by MULTISIG\_ROLE.*

```solidity
function setAllowedSlippage(uint16 _allowedSlippage) external requiresAuth;
```

### swapWith1Inch

Performs a swap using the 1inch Router, and enforces a slippage check.

*Callable by STRATEGIST\_ROLE.*

```solidity
function swapWith1Inch(
    bytes32[][] calldata manageProofs,
    address[] calldata decodersAndSanitizers,
    ERC20 tokenIn,
    uint256 amountIn,
    ERC20 tokenOut,
    bytes calldata data
)
    external
    requiresAuth
    enforceRateLimit;
```

**Parameters**

| Name                    | Type          | Description                                                                                                 |
| ----------------------- | ------------- | ----------------------------------------------------------------------------------------------------------- |
| `manageProofs`          | `bytes32[][]` | 2 manage proofs, the first one for the ERC20 approval, and the second for the router swap call              |
| `decodersAndSanitizers` | `address[]`   | 2 DecodersAndSanitizers one that implements ERC20 approve, and one that implements AggregationRouterV5.swap |
| `tokenIn`               | `ERC20`       |                                                                                                             |
| `amountIn`              | `uint256`     |                                                                                                             |
| `tokenOut`              | `ERC20`       |                                                                                                             |
| `data`                  | `bytes`       |                                                                                                             |

## Events

### SlippageUpdated

```solidity
event SlippageUpdated(uint16 oldSlippage, uint16 newSlippage);
```

## Errors

### DexAggregatorUManager\_\_Slippage

```solidity
error DexAggregatorUManager__Slippage();
```

### DexAggregatorUManager\_\_NewSlippageTooLarge

```solidity
error DexAggregatorUManager__NewSlippageTooLarge();
```
